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:
I don't know what you're seeing when you run the code but I'd change it as below to update labels without overwriting existing ones.
def customFieldA = getFieldById("customfield_25202")
def labelsField = getFieldByName("Labels")
def customFieldValue = customFieldA.getValue()
def existingLabels = labelsField.getValue() as List ?: []
if (customFieldValue) {
if (!existingLabels.contains('Incident')) {
existingLabels.add('Incident')
}
// Remove 'No_incident' if present
existingLabels.remove('No_incident')
} else {
if (!existingLabels.contains('No_incident')) {
existingLabels.add('No_incident')
}
// Remove 'Incident' if present
existingLabels.remove('Incident')
}
labelsField.setFormValue(existingLabels)
@Tuncay Senturk not related to this one, can we hide the child option (secondary one of the field) in a cascading field? is there a way to do it ?. If yes can you show me the way please.
Meanwhile ill try with the above code, thanks so much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.