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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 26, 2019

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 27, 2019

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"

Like Mahesh Kallepalli likes this
TAGS
AUG Leaders

Atlassian Community Events