Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Validator - Multiselect Field (Cloud)

Fabian
March 24, 2022

I currently setting up a workflow validator in Jira Cloud using Scriptrunner.

I was able to get the value of a single select field like this: issue.customfield_10040.value == 'Home' 

Now I'm trying to get the values of a multi select field but it's not working. 

I used issue.customfield_10039[0].value == "USA" but as the field can have up to 10 entries this seems not to be the right way. 

What am I doing wrong here? I hope somebody can help me.

 

Thank you.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Roland Holban (Adaptavist)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 27, 2018

Here is an example I wrote up that should demonstrate all the steps necessary. Use it as a template script for your post-function and modify it to suit your needs.

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager

def cfDropDown = customFieldManager.getCustomFieldObjectsByName("cfDropDown")[0]
def cfArtist = customFieldManager.getCustomFieldObjectsByName("cfArtist")[0]
def cfEngineer = customFieldManager.getCustomFieldObjectsByName("cfEngineer")[0]

def cfDropDownValue = issue.getCustomFieldValue(cfDropDown)
def cfEngineerValue = issue.getCustomFieldValue(cfEngineer)
def cfArtistValue = issue.getCustomFieldValue(cfArtist)

if (cfDropDownValue.value == "Option A") {
issue.setAssignee(cfArtistValue)
} else if (cfDropDownValue.value == "Option B") {
issue.setAssignee(cfEngineerValue)
}
TAGS
AUG Leaders

Atlassian Community Events