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

  1. Go to Administration > Issues > Workflows.
  2. Select Edit on the workflow you want to add a condition to. 
  3. Select the transition to which you wish to add a condition.
  4. Under Options, select Conditions.
  5. On the Transition page, select Add condition.
  6. Select Custom script condition [ScriptRunner].

  7. Select Add.
  8. Optional: Enter a note that describes the condition.
  9. Enter an inline script of your choice. 

  10. Optional: Select Preview.
  11. Select Update.

  12. 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.


Related content

On this page