Automatic rule not working - sum/multiply between custom fields

Sara Valoti SK June 3, 2024

Hi everyone!

I want to create an automatic rule for the following custom fields: aaa, bbb, ccc, ddd, eee, fff, ggg, hhh, iii, jjj).
The formula I would like to apply is as follows:
(aaa*bbb)+(ccc*ddd)+(eee*fff)+(ggg*hh)+(iii*jj).

My rule works for the first two elements: (aaa*bbb)+(ccc*ddd)
But it doesn't work if I include the remaining part.

{{#=}}{{issue.aaa}} * {{issue.bbb}}+{issue.ccc} * {{issue.ddd}}+{{issue.eee}} * {{issue.fff}}+{issue.ggg}} * {{issue.hhh}}+{issue.iii}} * {{issue.jjj}}{/}}

What is wrong with this formula?

Thank you in advance.

2 answers

1 accepted

1 vote
Answer accepted
Stevan Mandić
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.
June 3, 2024

@Sara Valoti SK  maybe you should try with parentheses ()

{{#=}} ({{issue.aaa}} * {{issue.bbb}}) +({{issue.ccc}}* {{issue.ddd}}) + .....{/}}

Sara Valoti SK June 4, 2024

Thanks @Stevan Mandić  but unfortunately I think the problem is not that. :(

0 votes
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.
June 3, 2024

Hi @Sara Valoti SK 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

What do you observe happening that leads you to believe the formula is not working?

What are the types of your fields: text, number, selection, etc.?  The types of the fields will impact how they are referenced / used in math operations.

Kind regards,
Bill

Sara Valoti SK June 4, 2024

Hi @Bill Sheboy,

after careful verification, I can say that my formula works once yes and once no.

I will describe the specific situation so that I can clarify the problems I am facing.

The formula I would like to make work is as follows:
{{#=}}{{issue.Quantity First Item}} * {{issue.CAD Price First Item}}
+{{issue.Quantity Second Item}} * {{issue.CAD Price Second Item}}
+{{issue.Quantity Third Item}} * {{issue.CAD Price Third Item}}
+{{issue.Quantity Fourth Item}} * {{issue.CAD Price Fourth Item}}
+{{issue.Quantity Fifth Item}} * {{issue.CAD Price Fifth Item}}{/}}

Sometimes it works, sometimes it doesn't. What could be the problem?

See the attached screenshots.
I hope they are helpful!
Thank you in advance for your time and help.

 

screenshot 1.jpgscreenshot 2.jpgscreenshot 3.jpgscreenshot 4.jpg

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.
June 4, 2024

Thanks for that information, and...

When you describe it does not work consistently, have you checked the following:

  1. Are the types of the fields all numeric?
  2. Do the fields all have numeric values?
  3. Have you confirmed the smart values are correct for the fields?  Please use this how-to article to do that: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
  4. When it "works" does the value match what you expect?
  5. When it "does not work", what do you observe happening?
Stevan Mandić
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.
June 5, 2024

@Sara Valoti SK  

1. Field to monitor changes: some words are lowercase (in Edit Field expression everything is uppercase)

2. I have tested your expression (it works). The only case when it doesn't work is when one or more number fields are empty. So each number field needs to have Value (you can set default value for custom field: 0)

3. Since you create variable with math expression during your automation, there is no need to repeat expression in edit field action. The value in edit field action can be: {{TOTALEpreventivo}} but it will work your way either (it's just redundant).

Also, in your expression, instead of using {{issue.Quantità primo articolo}} you can use {{issue.customfield_xxxxx}} where xxxxx is the ID of your custom field. (This would possibly solve the problem with lowercase, uppercase and letters like À.

Like Sara Valoti SK likes this
Sara Valoti SK June 8, 2024

Hi Stevan!
Exactly, it was just as you indicated: it was not working because while I was testing, not all the fields were complete. I then set as default values “0” so I did not encounter any more problems.
Thanks also for the clarification of the redundancy (in fact it seemed strange to me that I had to repeat the formula such and such also in the second field)
Thanks again for the support.

Like Stevan Mandić likes this

Suggest an answer

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

Atlassian Community Events