Workflow validator
Validate workflow transitions before they complete. One per script (singleton).
A Workflow Validator trigger executes your script every time an issue is about to transition through a specific workflow step. The script runs before the transition is applied - if the script blocks the transition, the issue stays in its current status and the user sees an error message.
Note: Workflow Validators are available in company-managed projects only.
Setup
- Save a script in the Library
- Go to the Config tab - Triggers
- Add Trigger - select Workflow Validator
- Configure the default error message (shown when the transition is blocked)
- Save the script
- In Jira Administration - Workflows, edit the desired workflow
- Select the transition you want to validate
- Add the Run Script - JiBrok Studio validator
- Select the configured script from the dropdown
Configuration
| Setting | Description |
|---|---|
errorMessage |
Default error message shown to users when the transition is blocked. If the script returns its own message, this is overridden. Default: “Transition validation failed” |
Context variables
The following variables are available in workflow validator scripts:
| Variable | Type | Description |
|---|---|---|
issue |
object | The issue being transitioned (auto-loaded) |
issueKey |
string | Issue key (e.g. "PROJ-123") |
event.issue |
object | Compact issue data (id, key) |
event.transition |
object | Transition details (see below) |
event.modifiedFields |
object/null | Fields modified during the transition |
currentUser |
object | Current user info |
Transition object
| Property | Type | Description |
|---|---|---|
event.transition.from_status |
string | Status before transition |
event.transition.to_status |
string | Status after transition |
event.transition.transitionName |
string | Name of the transition |
Return values
Warning: Workflow Validators use a fail-open design. If the script fails (runtime error, timeout, license issue), the transition is allowed. This prevents broken scripts from blocking all workflow transitions. Design your validators to explicitly return
{ valid: false }for all disallowed cases.
The script’s return value determines whether the transition is allowed or blocked:
| Return value | Effect |
|---|---|
{ valid: false, errorMessage: "..." } |
Block transition with a custom error message |
{ valid: false } |
Block transition with the default error message |
{ valid: true } |
Allow transition |
| Truthy value (string, number, non-empty object) | Allow transition |
Falsy value (null, undefined, false, 0, "") |
Block transition with the default error message |
| Script error (runtime exception) | Fail-open - transition is allowed |
Run as (actor resolution)
The script runs with the actor configured on the script. If no specific actor is set, the identity is resolved in this order:
- If set to Application - runs with app-level permissions
- If set to a specific user - runs as that user
- Otherwise - uses the Jira user who performed the transition
- Fallback - runs as Application
Limits
See Limits for execution time, API call, and other limits for workflow validators.
Example
// Block transition to "Done" if there's no assignee
if (event.transition.to_status === "Done" && !issue.fields.assignee) {
return { valid: false, errorMessage: "Please assign the issue before closing it" }
}
// Block transition if summary is empty
if (!issue.fields.summary || issue.fields.summary.trim() === "") {
return { valid: false, errorMessage: "Issue summary cannot be empty" }
}
// Require a comment when rejecting
if (event.transition.transitionName === "Reject" && event.modifiedFields) {
log("Modified fields:", JSON.stringify(event.modifiedFields))
}
// Check story points are set before moving to "In Progress"
if (event.transition.to_status === "In Progress") {
const storyPoints = issue.fields.customfield_10016
if (!storyPoints) {
return { valid: false, errorMessage: "Story points must be estimated before starting work" }
}
}
// Allow the transition
return { valid: true }
See also
- Triggers Overview - All trigger types at a glance
- Workflow Post Function - Run scripts after workflow transitions
- Event Triggers - React to Jira events
- Limits - All execution and storage limits
