Validate multi select field during transition in Jira using Custom script validator

Hi All,

I have the following code snippet to validate the custom multi select field. I am using the below code in 'Custom script Validator' during the workflow transition.


import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.opensymphony.workflow.InvalidInputException

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); 
def textfield = customFieldManager.getCustomFieldObjects(issue).find { == 'Text field 2'}
custom = customFieldManager.getCustomFieldObjectByName("Test multi")
List<Option> options = (List<Option>) custom.getValue(issue)
for (int i = 0; i < options.size(); i++){

if ( !issue.getCustomFieldValue(textfield))
invalidInputException = new InvalidInputException("Test field 2 is required")
throw invalidInputException


I am not able to get the values in the multi select. I actually need to check for two values in the multi select. What I am doing wrong?


Thanks, Hemanth

1 answer

1 accepted

Hi Hemanth
I would suggest something like that:

def targetVersionField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Test multi");
def options = issue.getCustomFieldValue(targetVersionField) as List<Option>

def requiredOptions = ['Option 1','Option 4']

if (! ( options*.value.containsAll(requiredOptions) )){
        throw new InvalidInputException("Field '${targetVersionField.getName()}'  requires the following options: $requiredOptions")


where 'Option 1' and 'Option 4' are the required options

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,852 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot