Forums

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

Making fields required based off multiple field values using scriptrunning

Joe Harmon
Contributor
September 7, 2023

I would like to make a few fields required ("Phase 0 Date", "Phase 1 Date", and "Mfg Partner") if the following fields are selected ("Release Type" == "Hardware" & "Goal Type" == "1P Launch/Release").  I would like to do this when a transition occurs to "Development" 

I have Scriptrunner and Jira Data Center.  I have tried this with Behaviors, but it doesn't work.  Plus on behaviors, you can only key off of one field value not two that I can see.  I also have the option of doing this on a transition with the required validator from scriptrunner and doing it on a transition.  But it was not liking the formula.  Can anyone help?

This is the script I have:

 

def releaseTypeField = getFieldById(getFieldChanged())

def goalTypeField = getFieldById(getFieldChanged())

def releaseType = releaseTypeField.getValue()

def goalType = goalTypeField.getValue()

def mfgPartner = getFieldByName("Mfg Partner")
def pg0 = getFieldByName("Phase 0 Date")
def pg1 = getFieldByName("Phase 1 Date")

if (releaseType == "Hardware" & goalType =="1P Launch/Release") {

    mfgPartner.setRequired(true) //Sets the SKUs field to required.
    pg0.setRequired(true) //Sets the SKUs field to required.
    pg1.setRequired(true) //Sets the SKUs field to required.
   
}
else {
    mfgPartner.setRequired(false) //Sets the SKUs field back to optional
    pg0.setRequired(false) //Sets the SKUs field to optional
    pg1.setRequired(true) //Sets the SKUs field to optional
}
This is the configuration I have:
image.png

0 answers

Suggest an answer

Log in or Sign up to answer