Workflow Conditions
Workflow Conditions control whether a transition button is visible and clickable for a user. If the condition evaluates to false, the transition is hidden.
How Conditions Work
- User views an issue
- Jira asks ScriptForge: "Should this transition be available?"
- Your condition script runs and returns
trueorfalse - If
true→ transition button appears - If
false→ transition button is hidden
Fail-open behaviour: If your script throws an error, the condition defaults to true (button is shown). This prevents broken scripts from permanently hiding transitions.
Writing a Condition
Conditions are JavaScript expressions or scripts that return a boolean. They have access to the issue context.
Example: Only allow senior developers to close issues
// Only show "Close" transition to users in the 'senior-devs' group
const user = await Users.getLoggedInUser();
const groups = await user.getGroups();
return groups.some(g => g.name === 'senior-devs');
Example: Block transition unless all sub-tasks are done
const issue = await WorkItems.getByKey(context.issueKey);
const subtasks = await issue.getSubTaskObjects();
// Only allow if all sub-tasks are in "Done" status
return subtasks.every(sub => sub.status === 'Done');
Example: Only allow transition if a custom field is set
const issue = await WorkItems.getByKey(context.issueKey);
const approver = issue.getCustomFieldValue('Approver');
return approver !== null && approver !== '';
Example: Time-based condition — only allow during business hours
const now = new Date();
const hour = now.getUTCHours();
const day = now.getUTCDay();
// Monday-Friday, 9am-5pm UTC only
return day >= 1 && day <= 5 && hour >= 9 && hour < 17;
Configuration
When adding a ScriptForge condition to a workflow transition:
- Select ScriptForge Condition from the available condition types
- Enter your script in the configuration panel
- Save the workflow
The condition is evaluated every time the issue view loads (to determine which transitions to show), so keep conditions lightweight and fast.
Tips
- Conditions run frequently (every issue view). Avoid heavy operations like large JQL searches.
- Use
awaitfor async operations (HAPI calls, user lookups). - Return
trueto show the transition,falseto hide it. - If you need the same condition on multiple transitions, consider creating a reusable function in Script Manager.