Workflow Validators
Use workflow validators to enforce rules when a user attempts a transition.
- Use expression-based validators to ensure a rule is met at transition time without writing a full script.
- Use scripted validators to implement complex checks that depend on multiple fields or related work items.
Atlassian has updated its workflow terminology as part of the new workflow editor experience. Some names and concepts may differ from what you're used to in the classic editor. For a detailed description of the changes, refer to Atlassian's official workflow documentation.
Supported spaces
Workflow rules are available in company-managed spaces only. Team-managed spaces are not currently supported.
ScriptRunner's workflow rules do not appear as options when you edit a team-managed workflow, so you cannot add them there.
Scripted workflow validators
In the Jira workflow editor, a scripted validator is the rule called Validate using a script (ScriptRunner). Your script returns whether the transition is allowed, along with an optional message explaining why it was blocked.
Scripted workflow validator reuse
You can create a scripted workflow validator once in ScriptRunner and reuse it across multiple workflows and transitions. This helps you:
- Maintain common logic in a single place (for example, requiring a fix version or a comment).
- Apply consistent validation rules across spaces and workflows.
Output and logging
When you run a script, the output panel shows:
- Anything logged with
console.log(...). - The final value returned by your script with
return. - The error, if the script failed, with the full untrimmed error behind Full error.
Use console.log(...) for messages, intermediate values, or debugging. A validator returns an object with a result of true or false, and an optional errorMessage shown to the user when the transition is blocked.
Activity history
Saved workflow validators keep activity history, so you can review when they were run, and what the output was, making it easier to audit and troubleshoot. For how long activity is kept, see Run history retention.
Create a scripted workflow validator
Follow these steps to create a new scripted workflow validator in ScriptRunner:
Add your scripted workflow validator to a workflow transition
After you create a scripted workflow validator, attach it to a specific transition in a workflow:
Test a scripted workflow validator
You can test your scripted workflow validators against JSON data for work items before using them on real screens. This lets you confirm that your script behaves as expected for a specific work item. Test data is the JSON data that describes the work item and transition your scripted workflow validator runs against. For scripted workflow validators, the JSON data typically includes:
issue: the work item (for example,id,key)modifiedFields: the fields that are changing as part of the transition (for example,assignee,status)transition: basic details of the transition (for example,fromandtostatus IDs)user: the user attempting the transition (for example,accountId)context: additional information about where and how the validator is running (for example,cloudId,moduleKey, anduserAccesscontextToken: an identifier for the current validation context
The full test data is shown in the test panel so you can see exactly what data your workflow validator receives when the transition runs.
Test your workflow validator as follows:
Edit a scripted workflow validator
Use these steps to modify an existing scripted workflow validator:
Enable and disable your Scripted workflow validator
You can enable or disable scripted workflow validators:
- Globally in ScriptRunner (affects all transitions that reference the validator).
- Per transition in a specific workflow (affects only that transition).
Use global enable/disable when you want to stop a validator everywhere. Use transition‑level enable/disable when you only want to pause or remove it from a specific workflow path.
Enable or disable globally
To enable or disable a scripted workflow validator everywhere it is used:
Enable or disable a specific transition
To enable or disable a scripted workflow validator on a single transition:
Delete a scripted workflow validator
Remove scripted workflow validators you no longer need to keep your list organized and reduce clutter. When you delete a scripted workflow validator, it's removed from your active Workflow validators list and is no longer available on workflow transitions. Any workflows and transitions that referenced the validator may still run, but the deleted script will no longer run as part of those transitions.
To delete a scripted workflow validator:
Restore a deleted scripted workflow validator
When you restore a scripted workflow validator, it becomes available again in ScriptRunner and is reconnected to any active workflows and transitions that previously used it. Those transitions will start running the validator script again the next time they are executed, and the validator's activity history remains available.
To restore a deleted scripted workflow validator:
- In Jira administration, select Marketplace apps.
- Under Apps, select ScriptRunner.
- Select Workflow validators.
- Use the filter and select Deleted to view deleted scripted workflow validators.
- Find the scripted workflow validator you want to restore.
- Open the ellipsis (…) menu for that validator.
- Select Restore.
Expression-based workflow validators
Use expression-based workflow validators to check a work item when a user attempts a transition. You write a Jira expression that must be true for the transition to go ahead, so you can require field values or enforce business rules without writing a full script. In the Jira workflow editor the rule is called Validate using a Jira expression (ScriptRunner).
What you configure
An expression-based validator has two settings, both required:
- Jira expression: an expression that evaluates to
trueorfalse. If it is false, the transition is blocked. - Error message: the message shown to the user when the validation fails. Write it to say what they need to change, because this is all they see.
Preview before you save
You can check your expression against a real work item before saving the rule. Expand the preview section, enter a work item key, and ScriptRunner evaluates your expression against that work item and shows the result.
This is worth doing for every validator. An expression that fails to evaluate, or that is true when you expected false, is much easier to spot here than after someone is blocked by it.
Create an expression-based workflow validator
You can also validate transitions using Jira expressions instead of scripts:
Edit an expression-based workflow validator
Use these steps to modify an existing expression‑based workflow validator:
Delete an expression-based workflow validator
To remove an expression-based workflow validator from a transition: