Forums

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

Sum two values using JIRA Automation

Vishal Biyani January 16, 2025

 

I want to sum values of two custom fields and save it in the third field.

When i write the rule like this

{ "fields": { "Total Effort": { "value": {{#=}}{{issue.customfield_10121}} + {{issue.customfield_10126}}{{/}} } } }

 I get the error:

 (Specify a number for the custom field (below 100,000,000,000,000) (customfield_10120))

if i write it like this:

{ "fields": { "customfield_10120": {{#=}}{{issue.customfield_10121}} + {{issue.customfield_10126}}{{/}} }

i get the error:

 

Error while parsing additional fields. Not valid JSON.

The custom fields are of datatype number

2 answers

1 accepted

7 votes
Answer accepted
Tomislav Tobijas
Community Champion
January 17, 2025

Hi @visby8em ,

Can you try using math expression directly in the field within Edit issue action (I'm assuming you're using this one?), and not necessarily advanced edit part of the action?

2025-01-17 09-01-47.png

For example, if the third field is also number type (where you're summing previous two values), automation could look something like in the picture above.

You could just use the expression

{{#=}}{{issue.customfield_10121}} + {{issue.customfield_10126}}{{/}}

and it should work.

If it doesn't, could you please provide screenshots of your rule together with audit log of error messages you receive?

Cheers,
Tobi

Vishal Biyani January 17, 2025

Thanks @Tomislav Tobijas 

Putting the expression directly works fine.

Like Tomislav Tobijas likes this
Mohamed Eid February 4, 2025

I tried to add days to a date and it didnt return an error but ofc the result isnt correct

-Expiration Date = Start Date: {{issue.description.substringAfter("This started at ").substringBefore(" ")}} + Remaining Days: {{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}

which is 

-Expiration Date = Start Date: 2025-01-18 + Remaining Days: 44.9999 -Expiration Date = Start Date: 2025-01-18 + Remaining Days: 44.9999

 

{{#=}}{{issue.description.substringAfter("This started at ").substringBefore(" ")}} + {{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}{{/}}

it gives this 

Log
2050.9999
Any ideas to fix this getting the right result for the expiry date ?
Tomislav Tobijas
Community Champion
February 4, 2025

Hi @Mohamed Eid

Would you mind sharing an example of a description here so I could test it out (can contain a dummy string; not necessarily a production one)? Also, please do share images of the rule together with the audit log (especially if you're using Log action to capture smart values and other outputs).

Also, I believe that the issue is this part of 'remaining days'? In the example, instead of 44.9999 it should be 50.0?

Btw, this parsing of textual fields can be a bit tricky, as it's expected that the field will always be in the same format.

If you like, you could also open a new question or a separate thread so we don't clutter this one.

Cheers,
Tobi

Mohamed Eid February 5, 2025

Hi @Tomislav Tobijas I have created a separate post already called do calculation please have a look

 

also for more details i ll post this

Log action: Start Date: {{issue.description.substringAfter("This started at ").substringBefore(" ")}} Remaining Days: {{issue.description.substringAfter("is expiring in ").substringBefore(" days")}}

 

Log action

Log
Log action: Start Date: 2025-01-18 Remaining Days: 44.9999
however when trying to create the expiration date which is the addition of both values it doesnt work

{{#debug}} {{ startdate("yyyy-MM-dd").plusDays(remainingdays.asNumber)}} {{/}}

Mohamed Eid February 5, 2025

it gave this 

Log action

Debug message
Log
Mohamed Eid February 6, 2025

@Tomislav Tobijas any idea please ?

Tomislav Tobijas
Community Champion
February 6, 2025

@Mohamed Eid let's just continue this in a separate thread (or even better, a separate post/question) so we don't create clutter here. I'll monitor the discussion that Vishal opened and jump in there if I can help.

Mohamed Eid February 6, 2025

yes please 

0 votes
Vishal Biyani
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.
February 5, 2025

As suggested on the other post, .toDate is missing 

try with this corrected statement:

{{#debug}} {{ startdate.toDate("yyyy-MM-dd").plusDays(remainingdays.asNumber)}} {{/}}

Mohamed Eid February 5, 2025
-Expiry Date =

Log action

Log
Debug message
Mohamed Eid February 6, 2025

@Vishal Biyani have you tested it ??

Vishal Biyani
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.
February 6, 2025

Yes. this is my audit log

snip.png

 

Can you share the screen shot of your rule to check if you have fixed the rule?

Mohamed Eid February 6, 2025

Provided the screenshots in the other post

Mohamed Eid February 6, 2025

please check the other post

Mohamed Eid February 6, 2025

in the other post

 

 

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