I need to update a select list (single choice) custom field as part of a workflow transition so I have tried the code provided in the link below
https://docs.adaptavist.com/sfj/set-a-select-list-custom-field-value-11468840.html
Unfortunately I get the error message below
Does anyone know how to fix this?
My code is
We are using Jira Software Data Center 8.20.8 and ScriptRunner 7.1.0
Thank you for your help
Your error is on this line:
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Change Request Priority")
Notice the 's' in getCustomFieldObjecsByName
This, and the error message indicating that a "getRelevantConfig" is no application to "Collection" means that you have a collection of custom fields. Not a single custom field object
Change that line to
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Change Request Priority")[0]
But also, it's better to use an explicit method/property to compare objects rather than the generaic "toString"
Here is a fully revised version of your script:
import com.atlassian.jira.component.ComponentAccessor
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Change Request Priority")[0]
def cfConfig = cfSelect.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.value == '5 - Urgent'
}
issue.setCustomFieldValue(cfSelect, value)
Dear @Peter-Dave Sheehan
Thank you for your help. It is highly appreciated.
I will test the new script as soon as possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.