Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Create Sub-Task Automatically when checkbox field values are checked Edited

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
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

909 views 2 22
Read article

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