Forums

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

Looking for direct advice including code on using custom calculated fields to output Risk Level

emcardo alarm July 10, 2018

Custom field 1 = 'Likelihood'

Custom field 1 single choice option = 1, 2, 3, 4, 5

 

Custom field 2 = 'Consequence'

Custom field 2 single choice option = 1, 2, 3, 4, 5

 

Custom field 3 = 'Overall Risk Score'

Custom field 3 is a calculated field (read only) and must calculated by field 1 x field 2

 

I dont see where you insert the calculation in the calculated field config?

I cant find any clear directives and I am not a programmer, but do have full JIRA admin access and experience in setting up JIRA, simply looking for calculated field direction

We have the custom misc fields add on already, so Im setup and ready to go assuming this is enough.

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
emcardo alarm July 10, 2018
David Fischer
Community Champion
July 11, 2018

Yes, that's the correct documentation. Let me know if you're having difficulties. 

David

emcardo alarm July 26, 2018

Hi David, finally got back to this.

I literally copy and pasted and updated the ref formula:

To add two custom fields, such as "Business Value" (or in my case Liklihood) and "Technical Value" (or in my case Consequence) to get an "Overall Value":


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


Now the next bit is weird, when I put field A as 2 and field B as 3, instead of addition, it concatenates together, Ie shows as 23, not 5

I have confirmed that this isnt a fluke either, change the entry fields, the output fields are concatenated.


emcardo alarm July 26, 2018

I thought it may be due to the fields types which are being used.

Both fields are 'Select list, single choice' fields where I simply list out 1, 2, 3, 4, 5 as the drop down options

Is it possible that JIRA is treating these as 'labels / words' rather than numbers?

That would explain the concatenation

I wanted the user to choose from limited set to ensure correct expected calculation, what would be a better custom field type to use?

David Fischer
Community Champion
July 27, 2018

Hi,

For Single-select list custom fields, issue.get returns a String representing the selected value (since the value can be any text, not necessarily numbers). So you need to convert the value to a number. Try this:

<!-- @@Formula: (issue.get("customfield_11001") != null ? Integer.parseInt(issue.get("customfield_11001")) : 0) + (issue.get("customfield_11000") != null ? Integer.parseInt(issue.get("customfield_11000")) : 0) -->
emcardo alarm July 29, 2018

You the man! Thanks SOLVED

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events