I would like to require a text field (or a single-select dropdown) based on the value selected in the Component/s field. (The custom fields are Acceptance Criteria and Code review required?)
I have:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def componentField = getFieldByName("Component/s")
def acceptanceCriteriaField = getFieldByName("Acceptance Criteria")
String componentValue = componentField.getValue()
if (componentValue == "AI Platform") {
acceptanceCriteriaField.setRequired(true)
}
else {
acceptanceCriteriaField.setRequired(false)
}
I am unable to make this work and could use some advice.
Hello Robbie,
I think the issue is that component/s is an array, and so a direct "==" comparison won't work.
Try something like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.component.ProjectComponent
def componentField = getFieldById("components")
def acceptanceCriteriaField = getFieldByName("Acceptance Criteria")
def componentValue = componentField.getValue() as List<ProjectComponent>
if (componentValue.any {it.name == "AI Platform"} ) {
acceptanceCriteriaField.setRequired(true)
}
else {
acceptanceCriteriaField.setRequired(false)
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.