Forums

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

Groovy Script is not working for Multi-select Custom Field

Kumar
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.
January 4, 2019

Hi Team,

In my Project I have a Multi Select Custom Field in that we have some Options so Here I'm performing Depends upon the Option Selected in the Multi List Field Another Custom Field has to appear or else those fields has to Hide.

// customfield_10001 is Single Select
// Customfield_10002 is Single Select

if(getFieldById("customfield_10001").getValue().equals("Other")){
getFieldById("customfield_10002").setHidden(false)
getFieldById("customfield_10002").setRequired(true)
}else{
getFieldById("customfield_10002").setFormValue(null)
getFieldById("customfield_10002").setRequired(false)
getFieldById("customfield_10002").setHidden(true)
}

This above Script is worked for the Single Select Custom Field but its not Working for the "Multi Select " Custom Field 

 

Can any One Suggest me Why its not working for Multi Select and can you please suggest me how to make it work for Multi Select List Custom Field 

or Is there any chance that to Convert the "Mult-select List" field to "Single-Select Field"

 

Thanks,

Kumar

 

1 answer

1 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
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.
January 4, 2019

It's the content that is the problem.  When you ask for the content of a single-select field, you get "empty" or the selected option.  When you ask for the content of a multi-select, you get "empty" or an array of one or many options - i.e. those selected.

Your code needs to take the returned "value" and iterate through it looking for the option(s) you want to detect.

But... I think (but have not tried in this context)... changing your ".equals" to ".contains" might be enough.

Kumar
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.
January 5, 2019

Hi @Nic Brough -Adaptavist-  Thanks for your response

Its worked thanks a lot

 

Thanks,

Kumar

Suggest an answer

Log in or Sign up to answer