Custom Script Condition
Use the Custom script condition to run an embedded script that determines whether an issue should be permitted to transition to a particular status within a workflow. This condition allows you to write Groovy scripts that can evaluate a wide range of conditions based on issue fields, workflow states, project properties, user permissions, and other contextual data.
With the introduction of HAPI, you can do what the Custom Script Condition does but in fewer lines when using our Simple Scripted Condition built-in workflow function. We therefore recommend, where possible, to use the Simple Scripted Condition over the Custom Script Condition.
If you need help writing your script, check out the Scripting tips page.
Use this condition
Condition functions
Condition functions determine if a transition should be visible for a particular issue. Jira runs condition functions frequently, it's therefore important to avoid doing any long processing in them.
To control whether a transition is permitted, you must set a variable named passesCondition
to true
or false
. By default, passesCondition
is true
, meaning the action will be allowed unless you explicitly set it otherwise.
Step-by-step instructions
- Go to Administration > Issues > Workflows.
- Select Edit on the workflow you want to add a condition to.
- Select the transition to which you wish to add a condition.
- Under Options, select Conditions.
- On the Transition page, select Add condition.
- Select Custom script condition [ScriptRunner].
- Select Add.
- Optional: Enter a note that describes the condition.
Enter an inline script of your choice.
- Optional: Select Preview.
Select Update.
Select Publish and choose if you want to save a backup copy of the workflow.
You can now test to see if this workflow condition works.