Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Maths with empty fields

Hi,

Hoping someone else has come across this scenario with Automation for JIRA.

I'm trying to perform a simple addition of numbers using an Edit action:

{{issue.customfield_12143}} + {{issue.customfield_12144}}

This works, but only if both customfields have values (aren't empty). Otherwise, I get errors:

Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number.

Some Number Field: +

I also tried setting default values in the calculation, but didn't seem to help:

{{issue.customfield_12143|0}} + {{issue.customfield_12144|0}}

 Any thoughts? All fields are plain old number fields.

 

TM

2 answers

Hi Timothy,

I'm surprised that the default isn't working for you. What version of Automation for Jira are you using?

Cheers,
Simeon [Automation for Jira]

Our production is 4.2.3, but I just upgraded out test instance to 5.1.4 and same result.

I worked around it by basically checking if each field used in the calculation is empty and setting to 0. Just seems clunky.

 

Hi Timothy,

Were you wrapping this operation with the maths operator?

{{#=}}{{issue.customfield_12143|0}} + {{issue.customfield_12144|0}}{{/}}

Cheers,

Simeon [Automation for Jira]

Like Dave Sausville likes this

Whereabouts on https://docs.automationforjira.com/working-with-issue-data/math-functions.html#where-to-use is this 

field|0

explained? I understand but searched for NULL and lots of other things before finding this community question.

I'm assuming it will solve this error:

Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number.

Total: 1038.46 +

^ note no value at the end because my custom field value was NULL.

Hi Martin,

Yes, it should help you out with that issue!

Cheers,
Simeon

Hi Martin,

For the record, my problem was never resolved. I just worked around it and moved on to other things! I was basing this off the Default Values functionality: https://docs.automationforjira.com/working-with-issue-data/smart-values.html#default-values

It's worked for text values in other situations, but I couldn't get it working with math operations. Not even wrapping it with the maths operator like Simeon suggested.

My workaround was breaking apart the operation into multiple automation steps, like:

  • If: matches {{FieldA}} equals Empty
    • Edit {{FieldA}}: 0
  • If: matches {{FieldB}} equals Empty
    • Edit {{FieldB}}: 0
  • Re-fetch Issue
  • Edit {{FieldC}}: {{FieldA}} + {{FieldB}}

And you could optionally wipe FieldA and FieldB if you didn't actually want the 0 value and have them show up on view screens, etc.

TM

Like Martin Cleaver likes this

@Simeon Ross - I actually did a quick test again and seems like the same thing is working now. We're on version 5.1.12. Were there any changes made since 5.1.4?

I literally enabled the old broken automation job (+ disabled the workaround one I made) and it worked under exactly the same circumstance that previously got an error. Either way, I guess it's behaving as expected now!

Like Martin Cleaver likes this

Hi Timothy,

Not that I know of that would have affect this behaviour. It should have been included in 5.1.4, glad it is working for you though!

Cheers,

Simeon.

Like Martin Cleaver likes this

For anyone who comes across this and doesn't understand why there's isn't working, this feature is sensitive to spaces

{{variable| 0}}

behaves as expected

{{variable | 0}} 

always returns 0 (note the space between the variable and the vertical line)

I'm not sure if this is intended behavior, but it made for a frustrating morning 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

How to log work and track time in Jira when a person is part of multiple teams

  The manager’s daily activities include a list of challenges to reach high levels of efficiency for their teams. Part of these challenges is related to how to deal with the worklog systems sin...

92 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you