Forums

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

Text Field to appear based on Drop Down selection

Jane Ellis June 16, 2021

Hello!

I would like to have a text box appear based on what Priority (Jira standard field) is selected. So if Highest or High Priority is selected I need my text box (custom field) to appear. So if the Priority Is Medium, Low, or Lowest, I don't want that text box to appear. Can anyone help with this on ScriptRunner?

I have been able to accomplish this with other field types, but not drop down fields.


Thank you.

1 answer

1 accepted

1 vote
Answer accepted
Max Lim _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.
June 16, 2021

This is a use case of ScriptRunner's Behaviour. It field return a Priority object.

1. Navigate: ScriptRunner > Behaviour > create and edit your Behaviour > add "Priority" field.

2. Add following server-side script:

def currentPriority = getFieldById(getFieldChanged()).getValue().name

if (currentPriority == "Hightest" || currentPriority == "High") {
getFieldByName("Your Text Field").setHidden(false).setRequired(true)
} else {
getFieldByName("Your Text Field").setHidden(true).setRequired(false)
}

I assume once the text field is shown, it is also required.

Above snippet will show a static type checking error, but it will work fine. To eliminate it, you need to cast currentPriority to the proper class Priority.

Jane Ellis June 17, 2021

Thank you so much! This will work for what we need! I appreciate your help. :)

Suggest an answer

Log in or Sign up to answer