Forums

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

Create a Calculated Text Field Converting Text Values to Numbers

Anthony Cardone
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 14, 2018

Hello,

I'm trying to create a Calculated Text field where I take 2 different custom fields, assign those text values a numeric value, and add them together. 

If both custom fields were numbers, I believe this code would work.

<!-- @@Formula: (issue.get("customfield_10114") != null ? issue.get("customfield_10114") : 0) + (issue.get("customfield_10150") != null ? issue.get("customfield_10150") : 0) -->

As an example:

Let's say I create 2 custom fields that are Select Lists (Single Choice) called Priority and Severity.
Each one contains the following values: High, Medium, Low, Not Applicable.
I want to assign a value of 5 to High, 3 to Medium, 1 to Low, and 0 to Not Applicable, and add those Priority and Severity totals together into a calculated field to return a value.

Can someone point me in the right direction? Thank you!

3 answers

Max Foerster - K15t
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 1, 2021

Good morning @DevOps-Tally. ,

the documentation was completely upgraded and moved some time ago. You can find it here now:

The function you are looking for has been renamed to Update field based on rules.

Best, Max

0 votes
arige hamdan August 8, 2019

Hi,

I found another shorter solution than suggested in your shared link above:

you can use this:

toNumber(%{id-customfield1})*toNumber(%{id-customfield2})

 

DevOps-Tally. July 30, 2021

Hey,Im very very new to coding and would need help in writing this from scratch.Even if you can help with a sample that i can edit that would be of great help. I have the same requirement and struggling to have a fix. 

0 votes
Anthony Cardone February 26, 2018

I'm responding to myself from my work account... I did find a way to do this using the Jira Workflow Tools plugin... This link outlines how to do it using their post functions and assigning numeric values to the words in the list options, and storing it in Ephemeral numbers, to then add it all up in a numeric custom field. 


https://bitbucket.org/fcarmario/jira-workflow-toolbox/wiki/amazing/Set%20a%20Field%20as%20a%20Function%20of%20other%20Fields


arige hamdan August 8, 2019

thanks a lot for sharing the solution.

Suggest an answer

Log in or Sign up to answer