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

Question

Question

Retrigger a formula?

asked on July 1, 2022

We have a couple of processes that calculate mileage using the Federal rate. Previously the rate had been hard-coded as a default value. We were alerted a few weeks ago that the rate would change for travel on or after 7/1/2022. At that time I removed the hard-coded value and created a simple formula for that would apply the proper rate depending on a return date (=IF(Return_Date_1<"7/1/2022",0.585,0.625)) and added it to all review tasks, but then I realized that the formula was not applying to requests already in progress (which has already used the hard-coded value) for travel after 7/1/2022. Is there a way to get the formula to recalculate/retrigger when review tasks are opened?

1 0

Answer

SELECTED ANSWER
replied on July 1, 2022 Show version history

Formulas and lookups do not not update if they were populated from a prior task step.  The way to get them to update again is to change the fields that feed into them.  Since your formula is referencing the Return_Date_1 field, a change to that field should trigger the formula to run again.

So you could instruct your reviewing team to edit that field.

If you'd rather do it automatically, and you are using the classic designer, you should be able to do it via Javascript.  Assuming your Return_Date_1 field has a CSS Class Name of returnDate, Javascript like this will probably work (it just triggers the change event when the form loads: 

$(document).ready(function() {

  //Trigger the change event of the returnDate field upon form load.
  //This helps ensure formulas are updated.
  $('.returnDate input').trigger('change');

});

 

0 0

Replies

replied on July 1, 2022

Matthew, thank you for this. It didn't work immediately - I played around with it and read through some more similar-ish posts. Once I changed the class name to the field number ($('#Field285').trigger('change');) it worked!

1 0
replied on July 1, 2022

Might have been because I had a typo and was missing an apostrophe ( ' ) in the code.  I just edited my original post to correct that.

I'm glad you've got it working. smiley

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

Sign in to reply to this post.