Subtraction does not work in jira automation

nasiruddin.nordin December 20, 2023

Hi all, 

 

I have an automation to calculate  as below : 

{{#=}} {{issue.customfield_1299|0}} + {{issue.customfield_1280|0}}{{/}}

 

but the outcome always just show the result of customfield_1299 instead of actually adding or subtracting from customfield_1280. 

 

When I tried like this : {{issue.customfield_1299|0}} + {{issue.customfield_1280|0}}

it will show something like this : 6 + 0

 

so customfield_1280 doesnt represent any value unfortunately. Can anyone help me on this please?

4 answers

0 votes
Johnny Mon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 26, 2023

Hi @nasiruddin_nordin ,

If we use the following, we will get an error instead of zero when both fields are EMPTY as noted in a similar community article here:

{{#=}}
{{issue.customfield_13400}} + {{issue.customfield_13401}}
{{/}} 

I think that's why you resort to using a "|0" to avoid an EMPTY value:

{{#=}} {{issue.customfield_1299|0}} + {{issue.customfield_1280|0}}{{/}}

But I think the above may result in text values inside {{#=}}, and I don't know how A4J handles it.  Thus, I think we got unexpected results.

 

Here my solution, using the IF mathematical expression - IF(condition,value_if_true,value_if_false)  instead of using {{field|0}}.

{{#=}}
{{IF(issue.customfield_13400,issue.customfield_13400,0)}}
+ {{IF(issue.customfield_13401,issue.customfield_13401,0)}}
{{/}}

The above works, because the mathematical IF(,,0) always returns a true numeric zero. 

 

Tests:

Setup (validate using issue NSP-25 custom fields 13400 and 13401)

test-web-request-validate-issue.png

A + B

a.plus.b.png

A + B (empty)

a.plus.empty.png

A (empty) + B

empty.plus.B.png

A (empty) + B (empty)

empty.plus.empty.png

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.
December 21, 2023

Hi @nasiruddin.nordin 

Context is important for automation rule questions.  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...

You note both fields are number types.  Have you confirmed that?

Have you confirmed the custom field id values you are using?  For example, by writing those individual smart values to the audit log to confirm they contain what you expected?

Kind regards,
Bill

0 votes
Mohammed Aamer Khan
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.
December 20, 2023

Hi @nasiruddin.nordin

Try using below smart values for addition
{{#=}} {{issue.customfield_1299.plus(issue.customfield_1280)}}{{/}}

0 votes
nasiruddin.nordin December 20, 2023

I have tried to do like this as well : 

{{issue.customfield_10299}} + {{issue.customfield_10280}}

Image 21-12-2023 at 12.57 PM.jpeg

and the result i got was 4.0+    

It does not detect the customfield_10280.

I have checked the type of everyfield and it is number fields so by right it should work :( 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events