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
Community Members
Community Events
Community Groups

Create Sub-Task Automatically when checkbox field values are checked


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)
//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

1 answer

0 votes

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.

Hi @Nic Brough _Adaptavist_ 


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.


def customFieldName = "Name of your custom field"

def chkBxFld = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"

Like Mahesh Kallepalli likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

285 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you