I found many answers in community here to get value from Select List (multiple choices) by using script post-function (ScriptRunner), but I'm still can't get it during if-else statement.
For example, using issue.getCustomFieldValue(), I can get the value of the selected list, it showed "Field Value: [Environmental Services]" in log, but it can't went through during if-else statement as username shows null.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
MutableIssue issues = issue
CustomField businessCat = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_23603")
String userName
log.warn("Issue: " + issue)
log.warn("businessCat Field: " + businessCat)
//def businessCatOptions = ComponentAccessor.optionsManager.getOptions(businessCat.getRelevantConfig(issue))
def businessCatValue = issue.getCustomFieldValue(businessCat)
log.warn("Field Value: " + businessCatValue)
if (businessCatValue == "Industrial Manufacturing and Processing Machinery and Accessories") {
userName = "jarevalo"
}
else if (businessCatValue == "Environmental Services") {
userName = "rasoni"
}
log.warn("username: " + user)
Example using ComponentAccessor.optionsManager.getOptions(), businessCatOptions get all the options from the Select List (multiple choices), but i don't know how to get the specific value such as "Industrial Manufacturing and Processing Machinery and Accessories" or "Environmental Services"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
MutableIssue issues = issue
CustomField businessCat = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_23603")
String userName
log.warn("Issue: " + issue)
log.warn("businessCat Field: " + businessCat)
def businessCatOptions = ComponentAccessor.optionsManager.getOptions(businessCat.getRelevantConfig(issue))
//def businessCatValue = issue.getCustomFieldValue(businessCat)
log.warn("Options: " + businessCatOptions)
if (businessCatOptions.findAll{it.value == "Industrial Manufacturing and Processing Machinery and Accessories"}) {
userName = "jarevalo"
}
else if (businessCatOptions.findAll{it.value == "Environmental Services"}) {
userName = "rasoni"
}
log.warn("username: " + user)
Any solutions or suggestions to recommend for me to implement?
Thanks