Conditions Templates
Conditions will prevent the user from transitioning an issue in Jira from one status to another unless the requirements for the condition are met. Conditions can be used to prevent users from starting a transition based on the requirements in the script. If a user has not met the condition the user may not ever know the transition was an available option.
The templates will create this condition process by adding a new condition script to an existing workflow transition within Jira.
Setting up the Condition Templates
Because the condition script needs to live in an existing workflow transition the first two steps to creating a condition script template will be selecting the workflow and transition for where the condition should be place.
If you are unsure which workflow to use an easy way to check is through the “view workflow” link that will present on any issue in Jira. Make sure you use an issue for the project and issue type you wish to add the condition to.
This “view workflow” link may not always be present due to permission settings. You may need to look in the project settings in order to determine which workflow you should select.
NOTE: Because the user will not be able to start the transition process if blocked by a condition script transition screens are not relevant to the condition script.
Testing the Script
Testing the script is as simple as trying to complete the transition while meeting/not meeting the condition set forth in the script.
Condition Met
If the requirements in the script are met the specific transition button will still appear as the “In Progress” button does below.
Condition NOT Met
If the requirements of the script are not met the user will not even be presented with the option to transition the issue to the In Progress status as the button does not appear.
Templates
User is
User is a defined user. If not, the option to transition the issue will not be shown to the user.
Inputs
Name | Required | Description |
---|---|---|
Select user | YES | The specified user who is allowed to complete the transition. |
Description | NO | The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script. |
Script
return currentUser() == "jmuse";
Hide transition from group/role
Hide transition if the user is not in a specific group or role.
Inputs
Name | Required | Description |
---|---|---|
Group | NO* | The group for which the user must belong to in order to pass the condition requirements. |
Project | NO* | The specific project the user must have an active role within. |
Role | NO* | The specific project roles for which the user must belong in order to pass the condition requirements. |
Description | NO | The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script. |
Group is required if not using project/role. Project and role are required if not using group.
Script
string group = "jira-administrators";
string role = "Developers";
string user = currentUser();
string[] roles = userRoles(project, user);
if(!userInGroup(group, user) || elementExists(roles, role)){
return false;
}