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

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

Calculation between 2 custom fields (Probability x Impact)

I hope you can help.
I have 2 custom fields (select list (single choice)) with values

  • unspecified
  • very unlikely
  • unlikely
  • likely
  • very likely
  • almost certain

with values of
0 = unspecified
1 = very unlikely
2 = unlikely
3 = likely
4 = very likely
5 = almost certain


  • unspecified
  • insignificant
  • minor
  • moderate
  • major
  • catastrophic

with values of:
0 = unspecified
1 = insignificant
2 = minor
3 = moderate
4 = major
5 = catastrophic

I'm a complete novice to ScriptRunner but what I would like to see is

As an example:
from Probability - if I was to select 'unlikely' and from
from Impact - if I was to select 'moderate'

I would want the outcome of 6 (2 x 3) appearing as an integer in another custom field.

I would appreciate you r help in the resolution


Version of ScriptRunner:

Version of JIRA (server) 8.3.3




1 answer

1 accepted

Hi @Amrik Birdi

For your requirement, I would suggest using the Scripted Field. For more information, you can visit the ScriptRunner Documentation.

Also, please update the current version of ScriptRunner you are using to the latest release i.e. 6.28.0 as there been many bug fixes since the current version you are using.

Below is an example working code for your reference:-

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager

def probability = customFieldManager.getCustomFieldObjectsByName("Probability")[0]
def probabilityValue = issue.getCustomFieldValue(probability).toString()
def probabilityMap = ["Unspecified" : 1, "Very Unlikely" : 2, "Unlikely" : 3, "Likely" : 4, "Very Likely" : 5, "Almost Certain": 6]

def impact = customFieldManager.getCustomFieldObjectsByName("Impact Option")[0]
def impactValue = issue.getCustomFieldValue(impact).toString()
def impactMap = ["Unspecified" : 1, "Insignificant" : 2, "Minor" : 3, "Moderate" : 4, "Major" : 5, "Catastrophic": 6]

def probabilityNumber = 0
def impactNumber = 0

if(probabilityValue != "null" && impactValue != "null") {
probabilityNumber = probabilityMap.find{ it.key == probabilityValue }.value as Long
impactNumber = impactMap.find{ it.key == impactValue }.value as Long
return (probabilityNumber * impactNumber) as Long

Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

To setup, the scripted field, go to the Fields option and select the Create Scripted Field option as shown below:-


Next, select the Custom Script Field option as shown below:-


Next, provide the Field Name you want to use and select the Number Field type as shown below:-


Next, add the code to the script field and Update it as shown below:-



Below are a few tests:-

1) First, create an issue and select the values for the Probability and Impact lists and create the ticket as shown below:-


2) The Scripted Field is only visible on the View Screen and not on the Create or Edit Screen. Once the issue has been created, the Scripted Field will display the output as shown below:-


3) Try updating the Probability or Impact options, and you will see the Scripted Field will update as well as shown below:-



I hope this helps to solve your question. :)

Thank you and Kind Regards,


Hi Ram

thankyou so much in getting intouch with me but for some reason or another its not working for me.

Is it possible to tell me where i need to make the modifications?


kind regards


Hi @Amrik Birdi

If you have just copied the code and pasted it in your environment, it will not work.

The differences that I have in my environment are

1) The Impact field in my environment is called Impact Option, as shown below:-

def impact = customFieldManager.getCustomFieldObjectsByName("Impact Option")[0]

 so you may need to rename the field in the code to match yours i.e.

def impact = customFieldManager.getCustomFieldObjectsByName("Impact")[0]

 2) The options from the list provided in the code contain Uppercase characters. However, in your description, you have only used lower case characters. You may want to take a look at that as well.

If you could share a print screen of your field configurations, i.e. for the Probability and the Impact field, it would be helpful.


Thank you and Kind Regards,


Hi @Ram Kumar Aravindakshan _Adaptavist_ many thanks for your answers. I have managed to modify accordingly

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

107 views 1 11
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