You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.