You are viewing limited content. For full access, please sign in.

Question

Question

Forms: refreshing the result of a calculation when one of the calculation's variables gets updated

asked on February 7, 2018

Laserfiche Forms Professional Version 10.2.1.246

I have a Form Field called "Expenses Total" which runs a function

  =SUM((SUM(PerDiem.DayTotal)), KM_Expense, Taxi_Cost, Other_Costs)

As the BP flows through approval stages, the values of the variables may get updated.  When the updates happen, SOMETIMES the =SUM function does not refresh its result to show the new SUM calculated with the new values of the 4 items being added.

This is intermittent.  Works most of the time, but not always. 

Most recent case, an Admin found the KM being claimed was wrong, so corrected the KMs, which caused KM_Expense to recalculate just fine.  Even though KM_Expense showed new value on the form,  "Expenses Total" did not update with a new output from its =SUM function which include the KM_Expense variable.

I need a REFRESH button on my form that forces all calculations, formulas / functions to re-evaluate when pressed.  All calculations are done within the Forms Field Variables and no java script is used because it is not supposed to be necessary to resort to java in Forms 10.

Does anyone have any idea how I might accomplish this [Refresh] ?

 

0 0

Answer

SELECTED ANSWER
replied on February 8, 2018

Hi Brett,

In your case when you noticed the wrong calculation, was it after form submission? When I tried to reproduce the issue, on user task page the values were updated but after approving the user task, the values were actually not updated.

If the above is true, I can confirm that this is a bug (id 39193) that did exist in 10.2.1 and has been fixed in Forms 10.3. Sorry for the inconvenience.

So is it possible for you to upgrade to 10.3? If not, can you open a support case and ask for an individual hotfix for 10.2.1?

1 0

Replies

replied on June 19, 2018

I have a workaround for those of us on 10.2.1.

I'll put the solution up first and then give some supporting info after.

$(document).ready(function(){
  
  setTimeout(function(){
  $('.totalSeed input').change();
  }, 1000);  

});  

For any total field, I assigned the class 'totalSeed' to the field that is being calculated. Not the total field, but the field where the total is being calculated from. After 1000 milliseconds .change() is called on that class. It triggers change for any field you put the class into.

I noticed that the total would recalculate if the input of the field changed. I could NOT do this using javascript .change() outside of the setTimeout. I tried .change() on the total field but that didn't work either. 

For some reason it needs a delay. I brought the number of milliseconds down to 1 and it worked. So, 1000 (1 second) is being extremely cautious. When I saw that it worked with 1 millisecond I thought the setTimeout might be unnecessary and I just needed to nest it in a function and then call the function. Nope. 

Maybe someone can figure out if this is a viable workaround to an extremely inconvenient bug.

Thanks,

Chris 

 

 

2 0
replied on October 16, 2018

I've been having the same issue with multiple forms and multiple processes. We're at 10.3.1.635. I just tried Chris' solution and put a timeout in one of my forms, where the calculation field refused to update. That seemed to resolve the issue. Is this going to be fixed in the next version of Forms or a hotfix? 

Thanks for the workaround, Chris!

2 0
replied on October 31, 2018

I've noticed this happen to one of my forms,  in the end I had to un-check the "read-only" option and assign this via javascript and for a change as well in javascript:

 

         $(this).find('.[class]').val([variable]).trigger('change');
         $(this).find('.[class]').attr('readonly', true);

1 0
replied on October 31, 2018

I already had this in my forms, and they still won't recalculate consistently. Sometimes they recalculate and sometimes they don't. But, it seems the fix Chris had works. I haven't tested it with all my forms yet though.

1 0
replied on February 7, 2018

Hi Brett,

Formula calculation should be updated when any of the variables used in the formula is updated, so a "Refresh" button should not be needed.

Can you give more description on the issue that calculation is not updated? How is KM_Expense calculated? What kind of fields are used and what is the value that is filled?

Is the KM_Expense field read-only? Will the formula be updated if manually update the KM_Expense field?

0 0
replied on June 19, 2018

@████████, can I use some javascript to trigger the field to recalculate? I have tried .change() and .trigger('change') on the input of the field in question. Any suggestions 'o master of the script?

Thanks!

 

0 0
replied on June 19, 2018

fyi, all my refresh issues disappeared when we installed the 10.3.x version

regards,

Brett

1 0
replied on February 8, 2018 Show version history

Thanks Rui Deng,

KM_Expense =KM_Driving*Mileage_Rate

Expenses_before_GST =DIV(Expenses_Non_Air,1.05)

GST_on_Expense =SUM(Expenses_Non_Air, MINUS(Expenses_before_GST))

Yes, the fields are "Read-only" which is supposed to be fully supported in 10.2???

To clarify, it is not just one value/calculation that does not update, there are 4 calculations and at any given instance any one of them may cling to an old value and fail to refresh.

Message Start Event Screen. Note the value of 550 KM @ 0.48 = $264 for travel distance resulting in a TOTAL EXPENSE = $514  which is generated correctly by the =SUM function shown in my original post

 

At Step 2, an Administrator reviews this claim and corrects Charles' KM value to 576 KM which updates the Kilometer Expense variable correctly to $276.48.  We should then see this 12.48 increase reflected in the EXPENSE TOTAL which SHOULD HAVE increased to $ 526.48.  Instead, the Expense Total keeps its original value of $ 514 .

 

We see this failure to refresh some calculated value happening about 5 times out of 100 and the customer is losing faith...

 

Here's another where the Expense Total updated but the 5% tax calculation is frozen with an old value of 599.05 and did not refresh to 899.09 when the Total increased to 944.04.

0 0
SELECTED ANSWER
replied on February 8, 2018

Hi Brett,

In your case when you noticed the wrong calculation, was it after form submission? When I tried to reproduce the issue, on user task page the values were updated but after approving the user task, the values were actually not updated.

If the above is true, I can confirm that this is a bug (id 39193) that did exist in 10.2.1 and has been fixed in Forms 10.3. Sorry for the inconvenience.

So is it possible for you to upgrade to 10.3? If not, can you open a support case and ask for an individual hotfix for 10.2.1?

1 0
replied on February 8, 2018

Thank you for letting us know.  We'll discuss the two options.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.