Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

The best way to calculate a number of custom fields in a sequential order in one automation rule

yousefq
Contributor
August 27, 2023

I’m using mathematical expressions to calculate a bunch of custom fields in a sequential order in one automation rule 

 

i.e to calculate the VAT field I’m using the following:

{{#=}} {{issue.Rent Amount}} * .15 {{/}}

 

then I’m using the output to calculate the total amount:

{{#=}} {{issue.Rent Amount}} + {{issue.VAT}} + {{issue.Other fees}} {{/}}

 

the problem is that sometimes the total amount doesn’t add the VAT 

My assumption is that there is some lag in filling the VAT field and by the time the automation runs the second line (Total amount), the VAT is still null. 


any recommendations on how to avoid this or if there is a better way to do these calculations?


much appreciated 

1 answer

1 accepted

4 votes
Answer accepted
Kseniia Trushnikova
Community Champion
August 27, 2023

Hi @yousefq,

Try to add the action Re-fetch issue data before calculation of the total amount. It refreshes smart values with the latest field values.

The other solution is to calculate all at once:

{{#=}} {{issue.Rent Amount}} + ({{issue.Rent Amount}} * .15) + {{issue.Other fees}} {{/}}

 

yousefq
Contributor
August 27, 2023

Thanks Kseniia

I wasn't aware there is an action to re-fetch the data

It worked nicely

Like Kseniia Trushnikova likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2023

Hi @yousefq 

Adding to the answer from @Kseniia Trushnikova ...the Re-fetch Issue action is helpful in this scenario, and it can slow down the rule by about 1 second per call.  (Which makes it helpful for other things too.)

When you have multiple, sequential and dependent calculations, using Re-fetch repeatedly could slow a rule down so much that it causes service limit problems.  For that case, it can be better to calculate your intermediate values and store them in Created Variables, use those in the math operations, and then update the issue once using the variables' values.

Kind regards,
Bill

Like yousefq likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events