Scripted field is getting evaluated for all issues

One of my JIRA admins created a scripted field that would take 3 number fields and add them together (see below). However, the fields that are being added are only present on one screen (which is the same screen that the scripted field resides on). However, I'm seeing a ton of errors in my logs that suggest that the scripted field is attempting to be evaluated on every issue that is opened up, even if the scripted field has not been added to any screens for that issue. The error looks like this:

2015-05-26 09:34:26,857 devstatus.applink:thread-2 ERROR JM28299 442x38x1 1slsrh3 /browse/PNTH-19283 [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: DM-534, field: Priority Value
java.lang.NullPointerException: Cannot invoke method getValue() on null object

I realize that the get Value on null object problem is something that needs to be fixed for the original script anyway (any assistance on that end would also be appreciated), but the main problem here is that it's attempting to run the script for all issues no matter what.... shouldn't it only be running on issues that have added that scripted field?
Here is the code for the scripted field (in its current state):

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
 // Creates Issue and Custom Field Manager objects
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
// Capture custom fields
CustomField customField_bv = customFieldManager.getCustomFieldObject( 13459 );
CustomField customField_ri = customFieldManager.getCustomFieldObjectByName( "Risk Index" );
CustomField customField_loe = customFieldManager.getCustomFieldObjectByName( "Level of Effort" );
CustomField customField_pv = customFieldManager.getCustomFieldObjectByName( "Priority Value" );
// Capture drop down values of custom fields
def businessValue = issue.getCustomFieldValue( customField_bv ).getValue();
def riskIndex = issue.getCustomFieldValue( customField_ri ).getValue();
def levelOfEffort = issue.getCustomFieldValue( customField_loe ).getValue();
// Only sum custom field values if NONE are null 
if (businessValue!= null && riskIndex != null & levelOfEffort != null)
    // Translate drop down values to double values 
    // Business Value 
    double businessValue_v;
    if (businessValue == "1 - Low") {businessValue_v = 1; }
    else if (businessValue == "2 - Medium") {businessValue_v = 2; }
    else if (businessValue == "3 - High") {businessValue_v = 3; }
    else {businessValue_v = 1000; } // should signal warning that a select drop down value is not recognized
    // Risk Index
    double riskIndex_v;
    if (riskIndex == "1 - User Interface") {riskIndex_v = 1; }
    else if (riskIndex == "3 - Management/Reporting") {riskIndex_v = 3; }
    else if (riskIndex == "6 - Process Improvement") {riskIndex_v = 6; }
    else if (riskIndex == "9 - Control/Error Prevention") {riskIndex_v = 9; }
    else {riskIndex_v = 5000; } // should signal warning that a select drop down value is not recognized 
    // Level of Effort
	double levelOfEffort_v;
    if (levelOfEffort == "3 - Low (< 4hrs)") {levelOfEffort_v = 3; }
    else if (levelOfEffort == "2 - Medium (5 - 11hrs)") {levelOfEffort_v = 2; }
    else if (levelOfEffort == "1 - High (> 12hrs)") {levelOfEffort_v = 1; }
    else {levelOfEffort_v = 8000; } // should signal warning that a select drop down value is not recognized
    // Return Summed Values
	return priorityValue  = businessValue_v + riskIndex_v + levelOfEffort_v;

3 answers

1 accepted

2 votes
Accepted answer

I believe this will be because your scripted field is still in the context of the project even if it is not displayed. Even if you never put a custom field on a screen you can still read its value or set it to something else.

You need to create a context in the "Custom Fields" admin area that confines the new field to only be relevant to the right project and the relevant issue types then it will stop evaluating for every issue in your instance.



Thank you, Michael, for your answer. This certainly makes the most sense out of everything I've read, and I will go and give it a try.

What does it do if we add a condition to filter it by current project and current issue type.


if (project == projectA) and (issuetype==Bug)
 execute bla bla bla


Let me know if this resolves your issue.



Chander Inguva



I have a workaround to make it stop producing all of the errors (I now do a null value check on the three custom fields), but I'd still like to know what the script is running on all issues even though the scripted field hasn't been added to those projects....

@Jamie Echlin [Adaptavist] Any ideas? I really need to figure out why these scripts get evaluated any time you look at any issue... even if that scripted field does not exist on that issue/screen....

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

956 views 3 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you