Want to update a select list type custom field vaule from null to a string (Should be one of the options from custom field} using groovy.
def changeHolder = new DefaultIssueChangeHolder();
officeRegion.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(officeRegion), officeRegionValue),changeHolder)
officeRegion --- Custom Field
issue --- Issue
officeRegionValue ----- New Value
is there any error in the above code or any event is needed to be fired to see the changes on UI ?
Thanks in advance,
Sumit
Community moderators have prevented the ability to post new answers.
I believe that you cannot set a select list to a string value. You need an object of type Option of the option you want to set the select list to.
In your call to the ModifiedValue constructor, the second parameter needs to be the Option object of the desired value.
In case you don't know how to get the option object, you can use the findByOptionValue method of the OptionsManager(https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/customfields/manager/OptionsManager.html).
I am able to see the changes now .. thanks Guys .. !!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried it .. is there anything needed to be done after the values are changed ... as even for my code the values are getting upadted on the first run but I am not able to see the changes on UI.
I dont want to restart the system to get the changes done
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
something you need to try like this
CustomField customField = customFieldManager.getCustomFieldObject(customFieldId); Options options = WebAppsCf.getOptions(null, customField.getRelevantConfig(issue), null); Option newOption = options.getOptionById(newOptionId); ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(customField), newOption ); customField.updateValue(null, issue, mVal, new DefaultIssueChangeHolder());
check this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.