Hello ,
We are having a checkbox custom field while creating a ticket when checkboxes are checked automatically a subtask has to be created. Please find below the code that I have implemented in the listener. Can anyone review my code and suggest to me on the right track.
def createSubtask = false
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def chkBxFld = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_10563');
def selectedOption = issue.getCustomFieldValue(chkBxFld)
log.warn('selectedOption'+selectedOption.toString())
//def myFieldList = ["Decision Pro","Laser Pro","Credit Quest","Kroll"];
//for(option in myFieldList){
if(selectedOption=='Kroll'|| selectedOption=='Laser Pro'|| selectedOption=='Credit Quest'|| selectedOption=='Decision Pro'){
createSubtask = true
}
//}
return createSubtask
The options selected are not strings, they are option objects. If you want to work with just the option's name (as it appears to your humans), you should use .getValue() to get the name out of the option.
Thanks for your response..!!
def chkBxFld = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_10563');
we are getting null pointer exception on null object , Can you guide me on right track with my code as i'm new to scripting.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try
def customFieldName = "Name of your custom field"
def chkBxFld = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.