I've been trying to create a script that will update a JIRA custom field (named CustomerJob) upon issue creation. I don't get any errors in the script, but it does not seem to be updating the field properly.
Below is the code I am trying to use. I apologize if it is a little messy as I have tried numerous things to no avail.
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
def cfCustomerJob = customFieldManager.getCustomFieldObjectByName("CustomerJob");
def cfCustomerJobValue = issue.getCustomFieldValue(cfCustomerJob);
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
if (cfCustomerJobValue[0].toString().equals("ABC"))
{
OptionsManager optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class);
Option option = optionsManager.getOptions(cfCustomerJob.getRelevantConfig(issue)).getOptionForValue("XYZ", null);
List<Option> newCustomerJob = new ArrayList<Option>();
newCustomerJob.add(option);
cfCustomerJob.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cfCustomerJob), newCustomerJob), changeHolder);
}
Thanks in advance for the help.