Hello would like to enable behaviors for a bug Issue type that meets the following two conditions on the Resolve screen before the user can transition to Done.
Environment (custom field) = Production
Story Points (system field) = Is not null (i.e greater than zero)
If the environment is not production, don't require story points and allow to transition.
If the environment is production, require story points to be greater than 0 to transition.
Here is the script I've been trying to create based on research, but the setRequired portion is not working. Any suggestions would be greatly appreciated.
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldEnv = customFieldManager.getCustomFieldObjectByName ("Environment")
def fieldEnvValue = getCustomFieldValue(fieldEnv)
def fieldSp = customFieldManager.getCustomFieldObjectByName ("Story Points")
def fieldSpValue = getCustomFieldValue (fieldSp)
if (fieldEnvValue == "Production" && fieldSpValue != null) {
fieldSp.setRequired(true)
UserMessageUtil.success('Add some points! ')
}else{
fieldSp.setRequired(false)
}