Related Versions
Jira v8.5.1
Scriptrunner v5.6.14.1-p5
I have several Behavior scripts that are showing/hiding fields based on other field selections. This part is working great.
My question is in regards to clearing options if the mainField options changes.
Heres My Code:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def mainField = getFieldById(getFieldChanged())
def applicationOther = getFieldById("customfield_13737")
def newJiraProject = getFieldById("customfield_13701")
def jiraProjectName = getFieldById("customfield_13702")
def jiraProjectKey = getFieldById("customfield_13703")
def jiraProjectLead = getFieldById("customfield_13704")
def jiraProjectAdmin = getFieldById("customfield_13818")
def businessJustification = getFieldById("customfield_13705")
def copyConfig = getFieldById("customfield_13707")
def selectedOption = mainField.getValue() as String
if (selectedOption != "Jira" || "Other") {
applicationOther.setHidden(true)
newJiraProject.setHidden(true)
jiraProjectName.setHidden(true)
jiraProjectKey.setHidden(true)
jiraProjectLead.setHidden(true)
jiraProjectAdmin.setHidden(true)
businessJustification.setHidden(true)
copyConfig.setHidden(true)
applicationOther.setRequired(false)
newJiraProject.setRequired(false)
jiraProjectName.setRequired(false)
jiraProjectKey.setRequired(false)
jiraProjectLead.setRequired(false)
jiraProjectAdmin.setRequired(false)
businessJustification.setRequired(false)
copyConfig.setRequired(false)
}
if (selectedOption == "Jira") {
newJiraProject.setHidden(false)
newJiraProject.setRequired(true)
}
if (selectedOption == "Other") {
applicationOther.setHidden(false)
applicationOther.setRequired(true)
}
I would like the fields that the selectedOption = Jira / Other exposes/hides to clear values if values are set.
I have a workaround to clear the values on Create but this is not a long term solution.
Any assistance is appreciated.