Forums

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

Auto populate Multi select custom field value using scriptrunner

RM August 28, 2023

Hi Team,

we have Cust name Multi - 80 values and MAID Multi 80 values if any of the Cust name Multi is selected MAID Multi should populate the multiple values how to achieve this please

I was able to achieve for two values using scriptrunner not more than that. As i am new to scripting someone help me

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def clientName = getFieldById(getFieldChanged())
def maidID = getFieldByName("MAID Multi")
def clientNameVal = clientName.getValue().toString()

// Getting select field optionsdef selectCustomField = customFieldManager.customFieldObjects.findByName("MAID Multi")
def selectConfig = selectCustomField.getRelevantConfig(issueContext)
def selectOptions = ComponentAccessor.optionsManager.getOptions(selectConfig)

if(clientNameVal == "[aarkishpharma]"){
    maidID.setFormValue(selectOptions.findAll{it.value in ['900702']}*.optionId)
}else if(clientNameVal == "[acellapharma]"){
    maidID.setFormValue(selectOptions.findAll{it.value in ['900025']}*.optionId)
}else if(clientNameVal == "[aarkishpharma, acellapharma]"){
    maidID.setFormValue(selectOptions.findAll{it.value in ['900702','900025']}*.optionId)
}

  

0 answers

Suggest an answer

Log in or Sign up to answer