Forums

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

Script runner behaviour question to avoid running it on form load where there are no changes

saravanan subramanian
Contributor
July 1, 2025

Hi TEam,

 

I have the code below to set the field "Severity Update Flag" when there are changes to the  field "PSIT Severity"  , how ever behavior below fires even when there is no change to the field PSIT Severity just when we click the edit button is there a way to avoid it?

Please let me know

 

 

 

 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = underlyingIssue
def tgtField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "PSIT Severity"}

// Get a pointer to both my fields
def demoSelect = getFieldByName("PSIT Severity")
def demoMultiTxt = getFieldByName("Severity Update Flag")

// Get the Value of the Select List Field
def selectedVal = demoSelect?.getValue()
def previousVal = tgtField?.getValue(issue)

if (selectedVal != null){
if (selectedVal?.toString()?.equalsIgnoreCase(previousVal?.toString())) {
    log.debug("Values are the same I will set the Val to False")
                String val ="False"
    demoMultiTxt?.setFormValue(val)
} else {
    log.debug("Values are different I will set the Val to True")
                String val ="True"
                demoMultiTxt?.setFormValue(val)
   
}
}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events