How can I set a selected list CF during transition?


I want to set a custom field value when the subtask is created.

The subtask is created during transition in the mainissue workflow. The custom field to be set is a single choice selected list in the subtask with the following options: "1", "2", "3", "4". I've already tried the following code:

def cf = customFieldManager.getCustomFieldObjects(issue).find{'Gate'}
issue.setCustomFieldValue(cf, '1')

 I've included the code in additional issue actions.

1 answer

1 accepted

Accepted Answer
1 vote

You need to use an option object, see Hennings answer:

 Thank you Udo Brand!


import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
def cf = customFieldManager.getCustomFieldObjects(issue).find{'Gate'}
def fieldConfig=cf.getRelevantConfig(issue)
issue.setCustomFieldValue(cf, value)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

41 views 0 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you