I want to show/Hide a field(multi line text box) based on option selected in multi select field. I a

Priyanka khare
Contributor
October 11, 2021

Hello,

 

I want to show/Hide a field(multi line text box) based on option selected in multi select field. I am using the below code but this only hides the "multi line text box" but never shows-

////////////

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


@BaseScript FieldBehaviours behaviours
def reasonForBlock = getFieldById("customfield_11842") //
def flaggedField = getFieldById("customfield_11829") //
def selectedOption = flaggedField.getValue() as String
log.debug "Selected option: $selectedOption"
if (selectedOption.toString().contains("Other")){

reasonForBlock.setHidden(false)
}
else {
if(reasonForBlock.value)
{
reasonForBlock.setFormValue(null)
}
reasonForBlock.setHidden(true)
}

 

Can someone help?

 

Regards,

Priyanka

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Lih Yao Tiong
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.
October 12, 2021

Hello @Priyanka khare

I had tried to run your script, and it's working fine on my end.
Please correct me if I got you wrong, I understand that you wish only to show the field while the "Other" option was selected on the multi-select field.
May I check if the multi-line text box will never show when you select the "other" option on the multi-select field?
Please make sure that you apply your Behaviour script as a server-side script to detect the changes everytime.

Sophia Chen
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!
October 19, 2021

hello,Lih Yao

I also want to try the script.Could I know how you run the script or where you run the script.

Lih Yao Tiong
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.
October 20, 2021

Hello @Sophia Chen ,

To run this script, you should need to install ScriprtRunner in your Jira.
Like I mentioned, please make sure that you apply this script as a Behaviour server-side script.

I would like to suggest you look at this document to understand how the script will work with Behaviour.

I hope this helps. :) 

Sophia Chen
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!
October 20, 2021

Thank you for your answer,Greatly appreciated! However,it‘s too expensive. We might not use this app.

Thanks again for your reply.

TAGS
AUG Leaders

Atlassian Community Events