How to set a custom field of type select list to a default value?

Jeetendra Dash December 1, 2017

while creating an Epic,I need to create an issue of type(Feature request) inside the epic .While creating issue of type(Feature request) I need to set a default value to a custom field of type select list.

def Discipline = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == "Discipline/s"}//here i am getting custom field object

 

CustomField customField = customFieldManager.getCustomFieldObject("customfield_11011");
def optionsManager = ComponentAccessor.getOptionsManager() ;
Options options = optionsManager.getOptions(customField.getRelevantConfig(issue));
Option newOption = options.getOptionById(new Long(11226)); // Check your option id
issue.setCustomFieldValue(Discipline, newOption)

 

But above code is not working.Could you please help me here.

Is this code is correct?or I need to modify here

0 answers

Suggest an answer

Log in or Sign up to answer