Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,217
Community Members
 
Community Events
168
Community Groups

Behavior Script erroring out

Edited

We've been using a set of behavior scripts to tally up a set of single select list fields into one number field that then sets the value of another single select list field.  The purpose of this script is to assess the risk, impact, and visibility of a proposed change to a system and then assign an impact score from I1 to I4.  This script has been working for years now but recently stopped.  I suspect it had to do with a recent upgrade to new Scriptrunner version v.5.8.0-p5

Here is the initializer script: 

/**
* @version 1.0
*
* This is the initialiser script to set the CMR Categorizarion Total field to 0.
*
*/

def totalField = getFieldById("customfield_10195")
totalField.setFormValue(0)

 and here is one of the field-level scripts:

/**
* @version 1.0
*
* The validation script that performs the capturing of field values and performing calculations for the total field
*
* This scrpt focuses on the CMR Categorization - Back Out Effort field
*
*/

// declare the field that will constantly change
def backOutEffort = getFieldById(getFieldChanged())

// declare other fields
def businessProcessChange = getFieldById("customfield_10212")
def changeExperience = getFieldById("customfield_10215")
def degreeOfVisibility = getFieldById("customfield_10214")
def systemImpact = getFieldById("customfield_10210")
def organizationalVisibility = getFieldById("customfield_10208")
def scopeOfChange = getFieldById("customfield_10213")
def totalField = getFieldById("customfield_10195")
def impactScoreField = getFieldById("customfield_10222")

def currentFieldValue = totalField.getValue().toString()
def total = Integer.valueOf(currentFieldValue)

// perform calculation here
total = backOutEffort.getValue() != null ? Integer.valueOf(backOutEffort.getValue().toString()) : 0
total += businessProcessChange.getValue() != null ? Integer.valueOf(businessProcessChange.getValue().toString()) : 0
total += changeExperience.getValue() != null ? Integer.valueOf(changeExperience.getValue().toString()) : 0
total += degreeOfVisibility.getValue() != null ? Integer.valueOf(degreeOfVisibility.getValue().toString()) : 0
total += systemImpact.getValue() != null ? Integer.valueOf(systemImpact.getValue().toString()) : 0
total += organizationalVisibility.getValue() != null ? Integer.valueOf(organizationalVisibility.getValue().toString()) : 0
total += scopeOfChange.getValue() != null ? Integer.valueOf(scopeOfChange.getValue().toString()) : 0

// set the total field value to what's been calculated
totalField.setFormValue(total)
log.debug "Current total value is ${totalField.getValue()}"

if (total >= 7 && total <= 11) {
log.debug "Total: ${total}; Impact Score: I4"
impactScoreField.setFormValue(10562)

} else if (total >= 12 && total <= 17) {
log.debug "Total: ${total}; Impact Score: I3"
impactScoreField.setFormValue(10561)

} else if (total >= 18 && total <= 23) {
log.debug "Total: ${total}; Impact Score: I2"
impactScoreField.setFormValue(10560)

} else if (total >= 24) {
log.debug "Total: ${total}; Impact Score: I1"
impactScoreField.setFormValue(10559)

} else {
log.debug "Total: ${total}; Impact Score: None"
impactScoreField.setFormValue("")
}

I'm getting the following errors in the atlassian-log file: 

 

2020-04-01 11:29:50,820 http-nio-80-exec-41 ERROR trossiter 689x1033025x1 1e2d0ov 10.190.17.149 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] *************************************************************************************


2020-04-01 11:29:50,820 http-nio-80-exec-41 ERROR trossiter 689x1033025x1 1e2d0ov 10.190.17.149 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] Script function failed on issue: (create issue) project/issuetype: CMR/CMR Standard, user: trossiter, fieldId: customfield_10213, file: <inline script>


Any help would be greatly appreciated. Thanks!

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events