Forums

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

How to add Null+Value

Neetu Verma
Contributor
April 1, 2020

I have 3 custom field which stores the estimation for 3 work categories.  They all are numeric fields.

Our Story point is the addition of all these 3 fields

 

I have this Math rule which works if 3 of these are valued

{{#=}} {{issue.customfield_12018}} + {{issue.customfield_12020}} + {{issue.customfield_12102}} {{/}}

But sometime not all 3 fields will be valued and then I get below error


Error rendering smart-values when executing this rule:Missing parameter(s) for operator +: + 0.25 +

Can someone help me to figure out how to handle Null

1 answer

1 accepted

15 votes
Answer accepted
John Funk
Community Champion
April 6, 2020

Hi Neetu - try this code which sets the value of the field to 0 first if it is missing a value:

{{#=}} {{issue.customfield_12018|0}} + {{issue.customfield_12020|0}} + {{issue.customfield_12102|0}} {{/}}

Neetu Verma
Contributor
April 6, 2020

OMG.. John

Thank you so much.. it worked. I cant even thank you enough for making this work. I am super glad I didn't put a workaround. 

 

Thanks

Neetu

Like • rcampos likes this
John Funk
Community Champion
April 6, 2020

Great! I am glad that worked for you.  :-)

Can you click on the Accept answer button above so we can close this one out? Thanks!

Mustafa Slatewalla May 28, 2021

Awesome !! This worked Well !!

Like • John Funk likes this
Jeshua April 10, 2024 edited

This is exactly what I needed as well, thank you @John Funk !!! The "|0" is brilliant and will be really useful for number fields in the future !

Like • John Funk likes this
John Funk
Community Champion
April 10, 2024

Great! Glad you found it useful. 

Like • Jeshua likes this
Harsh
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.
May 8, 2024

HI @John Funk 

I have a question related to this. Can we perform 'division' action as well using smart values. I could not find anything in documents as well. But instead of + I used '/'

I tried the similar approach {{#=}} {{issue.customfield_1245|0}} / {{issue.customfield_5656|0}} {{/}}

 

I am getting the following error:
Missing parameter(s) for operator /: 125 /

where 125 is the value customfield_1245.

 

Any suggestion would be a great help.

Thank you in advance.

John Funk
Community Champion
May 8, 2024

Hi @Harsh  - Not sure why that didn't work as that is the corrector operator. Though it sounds like it is not getting a value for customfield 5656. You could try doing a log action on that field or just update the field to have a 0 in it. You should always default number fields to 0 if you are planning on using them in automation. 

Harsh
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.
May 9, 2024 edited

Hi @John Funk 

Thanks for the update.
I updated the following rule with following input:

{{issue.customfield_1245|0}} = 125 / {{issue.customfield_5656|0}} = 5

I am expecting an answer of 25.

Option 1:

{{#=}}{{issue.customfield_1245|0}} / {{issue.customfield_5656|0}}{{/}}

Here I am getting the error:

Error rendering smart-values when executing this rule:
Division by zero: 1250.0 / 0

Option 2:

{{#=}}{{issue.customfield_1245.value|0}} / {{issue.customfield_5656.value|0}}{{/}}

Here nothing happens, rules does not run.
Option 3:

{{#=}}{{issue.customfield_1245.value}}/ {{issue.customfield_5656.value}}{{/}}

Here I get the following error

 

Error rendering smart-values when executing this rule:
Unknown unary operator / at character position 1: /

Option 4:

{{#=}}{{issue.customfield_1245}} / {{issue.customfield_5656}}{{/}}

Here I get the following error:

Error rendering smart-values when executing this rule:
Missing parameter(s) for operator /: 125.0 /
So all in all I tried all the possible match where the operator '/' can be used but no luck.
I think this is the issue of the operator?
Any help will be supported.
Thanks!
Harsh
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.
May 13, 2024 edited

Hi @John Funk 

Issue resolved. I  tried with other field and it did. Somehow JIRA was not able to take the value from the other field.

Thank you

Like • John Funk likes this
John Funk
Community Champion
May 21, 2024

Great! Glad it is working!

Suggest an answer

Log in or Sign up to answer