JSM - change a custom text field to required based on custom field value (single select)

deborah a plante
Contributor
February 10, 2023

Need this to work on customer request type, creation.

I have two fields on the customer request type

"Is a Supervisor?" Select List (single choice)

"Client Name " Text field (single line)

If Is a Supervisor? = N the Client Name field is required, otherwise it is an optional field

Using Scriptrunner behaviour

I create the following, and it requires the field, but it requires it all the time.  Appreciate any help.

Mapped to specific JSM project and Customer Type
Guide workflow is set

INitialiser:

import com.atlassian.jira.issue.resolution.Resolution

def dropDownCF = getFieldByName('Is a Supervisor?')
def requiredCF = getFieldByName('Client Name')
def valueCF = getFieldByName('Is a Supervisor?').value

if (valueCF == "No") {
requiredCF.setRequired(true);
} else {
requiredCF.setRequired(false);
}

Data Center
JIRA 8.20.1
JSM 4.20.1
ScriptRunner 6.39.0

1 answer

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 12, 2023

HI Deborah,

You will need an add-on like the ScriptRunner Behaviours app. 

deborah a plante
Contributor
February 13, 2023

Thank you, i am using scriptrunner

Like John Funk likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2023

Not just ScriptRunner, but the Behaviours app. 

deborah a plante
Contributor
February 13, 2023

I am not using the cloud version - i am on the data center version.  sorry if i did not tag this correctly.

Like John Funk likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2023

Oh - sorry, I missed that. I am not sure if Behaviours is included in the DC version of ScriptRunner or if it a separate app. But you will need to solve with the Behaviours tool. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events