Forums

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

Populate a field based on another multiselect field's

Musku Nagaraju
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 12, 2020

Hi Team, 

I have requirment, based on one custome field another custome field need to show or hide,

I have a code which is working fine for Single select field, but when I applied the same for Multislect field  its not working.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

log.warn("--- Start Behaviour ------------------------------------")

 

//partials Multiselect field

def Partial = getFieldById("customfield_14544")
log.warn("Partial = $Partial")

//Minor Text field

def Minor = getFieldById("customfield_14545")
log.warn("Minor = $Minor")

def PartialValue = Partial.getValue()
log.warn("Partial = $PartialValue")

if (PartialValue == "Others" ){
log.warn("Version set to hidden!")
Minor.setHidden(false)
Minor.setRequired(true)
}
else {
log.warn("Version set to hidden!")
Minor.setHidden(true)
}

log.warn("------------------------------------ End Behaviour ------")

1 answer

1 accepted

0 votes
Answer accepted
Musku Nagaraju
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2020

Working fine now with help of 

 

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

@BaseScript FieldBehaviours fieldBehaviours

log.warn("--- Start Behaviour ------------------------------------")

def multisSelectList = getFieldById("customfield_14544")
def Text= getFieldById("customfield_14545")

// Get the Value of My Select Field
def selectVal = multisSelectList.getValue()

// If the first option is selected in the multi select list then make the text field required.
if(selectVal.toString().contains("Others")){
Text.setHidden(false)
Text.setRequired(true) // Make text field required

else {
Text.setHidden(true)
}

Suggest an answer

Log in or Sign up to answer