Scriptrunner: make field mandatory based on dropdown value

Jemima James June 30, 2022

Hi

  1. Is there some website that lists out the groovy packages that can be imported for Jira?
  2. I would like to make a field mandatory based on certain values in a dropdown (when the issue is being updated). How do I achieve this using Scriptrunner? I am very new to this plugin and to groovy so I find it very confusing.

1 answer

1 accepted

1 vote
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 30, 2022

Hi @Jemima James ,

in order to do that you need to setup a behaviour provided by ScriptRunner.

In particular you need to get your dropdown value, perform a check on that value and make the other field mandatory.

Here a useful link https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

Hope this helps,

Fabio

Jemima James June 30, 2022

Hi @Fabio Racobaldo _Herzum_ 

I had already gone through the link before. But to get to my expected outcome, the available configurations dont help.

Seems I need to write a script but I do not know how to do that in groovy.

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 30, 2022

Hi @Jemima James ,

you can add the following code associated to your behaviour for project/issuetype and to dropdown field

def dropdownCF = getFieldByName("YOUR_DROPDOWN_FIELD_NAME"); 
def fieldCF = getFieldById("YOUR_FIELD_NAME"); 

String dropdownValue = dropdownCF .getValue();

if("YOUR_VALUE_FOR_MANDATORY_CHECK".equalsIgnoreCase(dropdownValue )){
fieldCF.setRequired(true);

} else {

fieldCF.setRequired(false);

}

Hope this helps,

Fabio

Suggest an answer

Log in or Sign up to answer