We have a requirement based on two custom fields.DAP reason (multi level cascading field) and reason code (single option selection field).
When selecting reason code values for Dropped Duplicate, Duplicate, cannot be tested in Create screen, DAP reason value should be "Not Applicable".
Please find the below code.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def ReasonCode = getFieldById(fieldChanged)
def ReasonCodeValue = ReasonCode.value.toString()
def DAPReason = getFieldByName("DAP Reason")
def optionManager = ComponentAccessor.optionsManager
def customFieldManager = ComponentAccessor.customFieldManager
def DAPReasonCustomField = customFieldManager.getCustomFieldObject(DAPReason.fieldId)
def DAPReasonConfig = DAPReasonCustomField.getRelevantConfig(issueContext)
def DAPReasonOptions = optionManager.getOptions(DAPReasonConfig)
def DRNewOptions
if(ReasonCodeValue == "Dropped - Duplicate") {
DRNewOptions = ["Not Applicable"]
} else if(ReasonCodeValue == "Duplicate") {
DRNewOptions = ["Not Applicable"]
} else if(ReasonCodeValue == "cannot be tested") {
DRNewOptions = ["Not Applicable"]
} else {
DRNewOptions = ["Requirement", "Design", "coding", "Not Applicable"]
}
def DRNewOptionsMap = [null: "None"]
DRNewOptionsMap += DAPReasonOptions?.findAll {
it.value in DRNewOptions
}?.collectEntries {
[ (it.optionId.toString()) : it.value ]
}
DAPReason.setFieldOptions(DRNewOptionsMap)
Welcome to the Community!
Could you please attach the error stacktrace you're getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.