Jira Expressions Library: Examples & Use Cases
This Jira expressions library provides practical examples and real-world use cases for using Jira expressions in workflow conditions and validators.
Last updated
This Jira expressions library provides practical examples and real-world use cases for using Jira expressions in workflow conditions and validators.
Last updated
In this library you’ll find ready-to-use Jira expressions for common workflow conditions and validators. Each example below illustrates a practical use case, such as making a field required or restricting transitions based on roles. These Jira expressions can be plugged into your to enforce custom rules.
Condition example: Require an assignee.
Issue must have work logged:
The issue assignee must be different from the issue reporter:
Assuming that you have a separate workflow for sub-tasks and want to allow a transition in sub-tasks only when the field in its parent has the value "SAP":
It depends what kind of field you are referring. If it is of the Select type, then you need to use .value suffix:
It is up to you to find out the id and type of your custom field. In Jira expression field, after issue.parent. start typing the name of your field, you will get suggestion, which you can click and id of the field will be entered for you. You will also get a syntax error in case a type of the field is incorrect, which will help you make it right.
Finally, if you don't have a separate workflow, then you can make the condition to be checked only for subtasks, i.e. if parent != null. e.g.:
Make the "Root Cause" field required if the resolution is set to "Fixed":
Make the "Fix version" field mandatory only when the resolution is set to "Done":
Make a field required if a "LabelA" label is set:
Summary starts with a string:
Summary starts with a string and is minimum 15 characters long:
A custom field with only serial numbers, can be empty. The serial number format should consist of two letters followed by a sequence of five numbers (e.g., AB12345).
The Original estimate field is stored as a number of seconds, e.g.: 4h = 4x60x60 = 14400.
Original estimate must be less than 4h:
The content of a multi-line text field in Jira can be represented either as a string or an ADF (Atlassian Document Format) object, depending on the field's renderer or view context. To handle the field content consistently, regardless of its type, you can declare a helper function as follows:
The description field is an exception, as it is always represented as an ADF (Atlassian Document Format) object. To check if it is not empty, use the plainText
property:
The following expression requires that the issue has some time logged before the transition can be completed:
In order to check if at least 1 hour has been logged in the issue, compare the value against the number of seconds stored in timeSpent:
if you want to ensure that time is logged during the transition (if you have a dedicated screen with the Log Work field), you can check against originalIssue
—which is a snapshot of the issue before the transition screen was opened:
The originalEstimate field holds the original time estimate in seconds.
For advanced scenarios, like detecting changes during a transition, use the Jira Expression Condition & Validator.
This expression ensures the field is set and was modified during the current transition.
Block a transition if the Fix Versions contains "-UPDATE""
Allow a transition if the parent option is equal to A:
In order to check the child option, you can use the following:
Allow transition if any of the parent's options is selected:
If a user selects "No" in a Radio Button field, then require a comment on the transition screen:
Use "issue.attachments[issue.attachments.length-1]" to access the last added file
Don't allow .bmp, .exe, .bat, jam.dev file extensions:
Information about commits and pull requests is stored in the Development field. The value of the field is a string with format as follows:
Use the includes method or any other available function that operates on strings to validate the state of the field.
When a pull request is open, the value should contain state=OPEN
; when it is merged, the value should contain state=MERGED
.
Due date is approaching in 2 days from now:
In the Close transition add Jira Expression Condition or Validator (WBB):
In the Approval transition add Jira Expression Condition or Validator (WBB):
Use following expression to allow only the Service Desk Team to submit tickets without a request type:
In the editor, after typing issue.
, start typing 'Request Type,' and you will receive a valid custom field ID suggestion.
Edit the workflow of issue type that you want to restrict
In diagram mode, select the Create transition arrow and click Validators in the properties panel.
Select the Validators tab and click on Add validator button
Add Jira Expression Validator (WBB)
For example, if you want only users with the 'Developers' project role to be able to create Story issues, add Jira Expression Validator to the Create transition with following settings:
For example, to make the Story Points field required during creation only for the Story issue type, use the following expression. If you press Ctrl + Space after typing issue.
, start typing "story" to get suggestions about the Story Points field key.
Note that thanks to our validator, there's no need to create separate workflows for each issue type.
You can find the request type ID by looking at the URL of the request type form settings page.
Go to: Project settings -> Request types -> Click on a chosen request type; the URL contains the ID, e.g.:
https://example.atlassian.net/jira/servicedesk/projects/KEY/settings/request-types/request-type/34/request-form
For simple checks, such as whether the field is set or above a threshold, consider using the —no expression needed.
A filename property is a string. Check other string methods:
Link type ID may vary between Jira instances. Use the from the Linked Issues Condition to learn how to construct a similar expression.