I have created a scripted custom field and if the field is not empty i want Incident to be added as label in the ticket along with other labels and if its empty i want No_Incident to be added in the ticket. I have tried my best to create the script using behaviours but none of them works. can you helpme with the script please. I have script runner and dont have jira automation plugin.
script:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
def customFieldA = getFieldById("customfield_25202")
def customFieldValue = customFieldA.getValue()
def labelsField = getFieldByName("Labels")
if (customFieldValue ) {
labelsField.setFormValue(['Incident'])
} else {
labelsField.setFormValue(['No_incident'])
}
This script is not working , not sure where it went wrong