Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,538
Community Members
 
Community Events
168
Community Groups

How to set value in a multi select?

 

Hi,

I am using the code below to set value in multi select field. The value is not being set. 

Please advice.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.ComponentManager

// Set to Team
CustomFieldManager sa_team_field = ComponentAccessor.getCustomFieldManager()
CustomField sa_team = sa_team_field.getCustomFieldObject('customfield_16334') //to Team
def config = sa_team.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(config)?.find { it.toString() == 'CUSTOMER MGT IND' }
issue.setCustomFieldValue(sa_team, value)

 

Thanks,

Swarna

1 comment

A multi-select field holds an array of options, not a single value.

If you wrap your selected option(s) in a list of some sort, you should find it posts ok.

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events