You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Set the List Value according to the Workflow Name


The Behaviour Initializer is used to set the option on a Single Select List according to the project's workflow name which is retrieved using the REST Endpoint.


In this example, when an issue is either being created or edited, the Behaviour Initializer automatically sets the value of a Single Select List based on the project's workflow name that is obtained from the REST Endpoint.


  • Jira Jira (8.12 - 8.22)
  • ScriptRunner for Jira ScriptRunner for Jira (6.56.0)
import com.atlassian.jira.component.ComponentAccessor import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours behaviours def listName = '' def workflowName = '' def listOption = '' def sampleList = getFieldByName(listName) sampleList.setFormValue(null) def applicationProperties = ComponentAccessor.applicationProperties def project = issueContext.projectObject final def baseUrl = applicationProperties.getString('jira.baseurl') def hostUrl = "${baseUrl}/rest/scriptrunner/latest/custom/getWorkflowNames?projectKey=${project.key}".toString() def response = hostUrl.toURL().text def workflowResult = response[1..response.length() - 2] if (workflowResult == workflowName) { sampleList.setFormValue(listOption) }
Discovered an issue? Report it here

Suggested for you