Hello - I've set an automation rule to sum multiple numeric value custom fields. The automation rule worked perfectly when I was adding two fields, but when I included more fields that I wanted to sum, I received the error below.
Here is the script in the Automation section:
{{#=}}{{customfield_10112}} + {{customfield_10113}} + {{customfield_10114}} + {{customfield_10115}} + {{customfield_10116}} + {{customfield_10117}} + {{customfield_10118}} + {{customfield_10120}} + {{customfield_10121}} + {{customfield_10122}} + {{customfield_10123}} + {{customfield_10124}}{{/}}
Looking for guidance here.
Hi @Matthew Pears ,
I could reproduce this behaviour in 3 ways:
Hope this helps and helps solving the problem.
Best
Stefan
Thanks for looking into this. I've checked all three items you mentioned, and everything seems to be correct. Still getting this error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl UPDATE
I plugged values in all of the fields I am attempting to sum. This worked. However, I dont want the rule to behave this way, as some of the fields wont have values at the same time.
So, how do I need to modify the code in my original message to reflect this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
aaaah.....okay.
Guess the easiest way that comes to my mind would be to set default value '0'.
Would that be a feasible way?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mainly the tough part of automation is to really be sure about the concrete use case/requirement, the specific conditions and specific action regarding use case and conditions. "random behaviour/conditions" is the opposite of automation.
Are there any special cases where it can be specified which of the fields should be filled and therefore summed up?
If this isn´t the case and all fields should always be summed regardless of value or not I would suggest to add the default value 0 as this is a identified as number and can be calculated. Otherwise the field is identified as empty which cannot be calculated.
Hope this helps.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl you're awesome. I set the default value to "0" which fixed my problem. The Automation works perfectly.
However in trying to add a new rule on the same issue, I am trying to multiply two fields, and now I am seeing some strange behavior. The automation is working, but it is multiplying the last value in the field. For instance:
Initial Value = 0
New Value = 5
New Value = 10
Where I would expect the rule to multiply the fields first new value (5), but it does not. However when I change the fields value to 10, then it finally multiplies by now the old value 5.
I need it to multiply the "newest value" in the field.
{{#=}}{{customField_10125}} * {{customField_10126}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AAAWESOME!!! Happy it works. You rock 💪
I would need more context here. Could you provide a screenshot of the field and name
BTW: You could also use the name of the field instead of the field_ID in smart values. That makes it easier to read and understand automation rule (especially for me as a reader) 😉
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello guys,
Is it possible to use this script to calculate using Asset attribute?
Ex.
Field 1: Worked hours (Number Field);
Field 2: Cost of the hour (Jira Asset);
Field 3: Total cost (Number Field)
(Field 3 = Field 1 * Field 2)
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Caio Cesar Covos
Try to use add-on , developed by my team - Cost Tracker for Jira Cloud .
It multiple People logs to People rates per hour, and you can generate reports with this data. Also, the Cost Tracker for Jira Cloud add-on allows you to track all your company's expenses.
It's free.
Example of report:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Caio Cesar Covos -- Welcome to the Atlassian Community!
Yes, you may perform a calculation like that in an automation rule. I recommend triggering it on a change to any of those three fields, including the result. (That will handle the case of someone altering it.)
Please look here for more information on such field calculations in rules: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm Running JSM DC 5.6.0, but on my installation something like this works really well:
{{#=}}{{customfield_10112|0}} + {{customfield_10113|0}} + {{customfield_10114|0}} + {{customfield_10115|0}} + {{customfield_10116|0}} + {{customfield_10117|0}} + {{customfield_10118|0}} + {{customfield_10120|0}} + {{customfield_10121|0}} + {{customfield_10122|0}} + {{customfield_10123|0}} + {{customfield_10124|0}}{{/}}
If you append the "|0" to the end of the custom field identifier, the sum will take the value as zero if the field is NULL. That should get rid of your error!
Definitely make sure all the fields you're summing are numerical fields only though.
Best regards,
Corwyn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please note that you can also use default values for smart-values. See the bottom of https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/
Something like this should work: {{customfield_22222|0}} (note the |0 at the end)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was sure there is something like
this but couldn‘t find the hint. That‘s awesome. Thanks so much 🙌🏼👌🏼
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked if your custom field's types are text or numeric?
If text, you may need to convert them to numbers in order to make a mathematical function work, such as: {{issue.myCustomField.asNumber}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.