based on custom field selection other custom field should pop up for the user

Naveen kumar May 30, 2021

Need to create a custom field with single choice and based on the selection other preferred custom fields should pop up in create screen. im using script runner plugin and im new to jira . please guide me  .

 

EX: A= B and C . If i select B some different option should pop up and if i select C another set of options should be poping up .

1 answer

1 accepted

1 vote
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 30, 2021

Hi @Naveen kumar  You can easily do this with the help of Behaviour of Script Runner :- 

def selectlist1 = getFieldById("customfield_35743")
def Testfield1 = getFieldById("customfield_36079")
def Testfield2 = getFieldById("customfield_36080")

log.debug("dropdown value" + selectlist1.getValue())
if (selectlist1.getValue() == "B") {
Testfield1.setHidden(false);
Testfield1.setRequired(true);
Testfield2.setHidden(true);
} else if (selectlist1.getValue() == "C") {
Testfield1.setHidden(true);
Testfield1.setRequired(false);
Testfield2.setHidden(false);
}

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 30, 2021

Add Server side script on Select List field beacuse other fields are hidding based on Select list.

Ilya Stekolnikov
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.
May 30, 2021

also i didn`t catch the meaning of "pop-up" so i can add some hint box for CF. For example

import com.onresolve.jira.groovy.user.FormField


FormField selectlist1 = getFieldById("customfield_35743") 
FormField Testfield1 = getFieldById("customfield_36079") 
FormField Testfield2 = getFieldById("customfield_36080")

def hint1 = """
<div class=\"aui-message hint\">
<p>Some information</p>
<p>Here you can see some info about CF - TestField 1</p>
</div>
"""

def hint2 = """
<div class=\"aui-message hint\">
<p>Some information</p>
<p>Here you can see some info about CF - TestField 2</p>
</div>
"""

log.debug("dropdown value" + selectlist1.getValue())
if (selectlist1.getValue() == "B") {
Testfield1.setHidden(false).setHelpText(hint1);
Testfield1.setRequired(true);
Testfield2.setHidden(true);
} else if (selectlist1.getValue() == "C") {
Testfield1.setHidden(true);
Testfield1.setRequired(false);
Testfield2.setHidden(false).setHelpText(hint2);
}

Like Vikrant Yadav likes this
Naveen kumar May 31, 2021

sorry for explaining it wrong not like pop up it should be visible thats what i was trying to mention there. apologies for the mistake done .

Suggest an answer

Log in or Sign up to answer