During issue creation, we make a custom field required, Regression Issue, in our JIRA workflow. It's only required during creation. We wanted to only force the requirement on new issues, not force all the previously created issues to update this field during edit. Currently, we have a ScriptRunner Behaviors script to make other custom fields visible and/or required when certain values are select in the "Regression Issue" field.
The problem arises with our SalesForce integration. When users create new issues using the remote API. The Regression Issue field doesn't register as required custom field.
As a workaround, I was hoping to take advantage of the Behaviour script again to recognize a specific custom field, SalesForce ID, that's set during creation. If a value is added (any value), then set "Regression Issue" select list to "No". However, I can't seem to get this to happen. I've also tried using certain user group as a criteria, but that's a no go too.
Is it possible to automatically force a field value change based on another field not being empty? I've included my current Behavior script.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def regressionIssueField = getFieldById(getFieldChanged())
def regressedVersionField = getFieldByName("Regressed from Version(s)")
def regressedBuildField = getFieldByName("Regressed from Build #")
def salesforceField = getFieldById(getFieldChanged())
String regressionIssueValue = regressionIssueField.getValue()
String salesforceValue = salesforceField.getValue()
if (salesforceValue) {
regressionIssueField.setRequired(false)
return
}
if (regressionIssueValue == "Yes") {
regressedVersionField.setHidden(false)
regressedBuildField.setHidden(false)
regressedVersionField.setRequired(true)
} else {
regressedVersionField.setRequired(false)
}
Thanks, Chuck
Unfortunately if your creating the issue through the REST API the behaviours are not applied. That is one of the limitations of behaviours explained here.
Your probably best off using a validator to make the field required which will still be applied when creating the issue via the REST API. If you want further customisation over the requiredness of the field you should consider writing a scripted validator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.