Make a field required based on a selection in another field

Matthew Knab May 26, 2023

A question was posed to me from a user who would like to set up something where when a check box is made within a screen's fields, that another field becomes mandatory. Is this possible?

1 answer

0 votes
Manoj Gangwar
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 26, 2023

Hi @Matthew Knab ,

 

For that, you need to use a Field Required (JMWE app) Validator, select the required field, and add a "Conditional Validation" script like:

issue.customfield_12345.value == "Regression"

where customfield_12345 is the custom field ID of field Source. This easiest way to insert the right field ID is to use the "Issue Fields" help tab below the editor.

OR

If you have scriptrunner then you can add a behavior like this.

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def regressionIssueField = getFieldById(getFieldChanged())
def regressedVersionField = getFieldByName("Regressed from Version")

String regressionIssueValue = regressionIssueField.getValue()

if (regressionIssueValue == "Yes") {
    regressedVersionField.setRequired(true)
} else {
    regressedVersionField.setRequired(false)
}
Matthew Knab May 26, 2023

Thanks Manoj! Where would be the best spot to set this up, in the workflow or somewhere else?

Manoj Gangwar
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 26, 2023

The Field Required (JMWE app) Validator, you can use in your workflow.

 

For 2nd option, You have scriptrunner then go to the manage apps>>ScriptRunner>>Behavior>>Create a new behavior>> Create a mapping for the project and paste the script under initializer.  

Matthew Knab May 26, 2023

And this would be setup as a Validator correct? I'm trying to find the best transition to attach it to. So far, I have tried to set it to a creation transition for a ticket, but it didn't seem to work.

Suggest an answer

Log in or Sign up to answer