Forums

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

Behaviours set multi value Select List

Xavier
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 Leaders.
September 7, 2018

HI All,

is it possible with a simple Behaviours script to select multi value from a SELECT List custom field ?

I try this :

def HAP = getFieldByName("RadioButton")
def HP2 = getFieldByName("Multiselect LIst")
def optionHAP = HAP.getValue().toString()

if (optionHAP == 'Yes') {
HP2.setFormValue(14018) 
HP2.setFormValue(14019) 
HP2.setFormValue(14021) 
HP2.setFormValue(14022)
HP2.setFormValue(14024)
}
else {
HP2.setFormValue("")
}

 

When I select Yes on My RadioButton, the only last value from select list is selected.

How I can force to select all values ?

Thanks in advance.

Regards

1 answer

0 votes
Xavier
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 Leaders.
September 9, 2018

OK, I finally found.

import com.atlassian.jira.component.ComponentAccessor

// set a select list value -- also same for radio buttons
def HP2 = getFieldByName("Multiselect LIst")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(HP2.getFieldId()).

def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsToSelect = options.findAll { it.value in ["option1", "option2", "option8"] }

 

HP2.setFormValue(optionsToSelect*.optionId)

Suggest an answer

Log in or Sign up to answer