Background priority calculation

Use case

The priority of an issue should be set automatically during creation and remain unchanged afterward. This is determined based on two custom fields: Impact and Probability.

To prevent manual changes, the priority field is only shown on the view screen - it’s not available during issue creation or editing.

🗒️ Prerequisite

Create two custom number fields: Impact and Probability. These fields will be used to calculate the issue’s final priority automatically during creation.

🛠️ Configuration

In the workflow editor, select the create transition and add a Update fields post function to set the desired field value.

Target issue*

Choose Current issue

Calculating the priority

The value of the priority field is in our case determined by calculating the average of two custom number fields Impact (in our case with the custom field id 13520) and Probability (in our case with the custom field id 13521) that the create set while the ticket creation

The calculation uses the avg() function to determine the mean value. The logic then checks whether this average is greater than or equal to in our case 3:

  • If the result is true, the priority is set to High (e.g., ID "10200").

  • If the result is false, the priority is set to Low (e.g., ID "10002").

Fields*

Select the priority field in the field list and set the value based on a parser expression. 

Expression*

Set the expression editor to General mode and enter the following expression:

%{avg([{issue.cf13520},{issue.cf13521}]) >= 3 ? "10200" : "10002"}

Use the corresponding priority IDs from your priority scheme. You can find these IDs by hovering over the priority options in the scheme configuration

Run as*

Choose Jira Workflow Toolbox app user .

Pro tip

It’s important to run this post function as the Jira Workflow Toolbox app user, since the field is not editable as it is not added to the edit screen of the issue. The App user has the necessary rights to perform the update even when the field has not been added.

Use case Workflow function Parser functions
Set the due date based on the priority

Update fields

getMatchingValue()

Obtain the difference between two dates

Update fields


Assign an issue to the user who last commented on it

Update fields


Add three days skipping weekends automatically to a Date Picker

Update fields


Keep parent's priority in sync

Update fields


Set the assignee based on the issue type

Update fields

getMatchingValue()

Set the fix version to affects version when resolving an issue

Update fields


Use the app user to update non-editable fields

Update fields


Automatically add incident reporters to problem tickets

Update fields

append()

fieldValue()

linkedIssues()

toStringList()

Copy labels of a sub-task to the parent issue upon closing

Update fields


Assign an issue to the project lead, if the issue is unassigned on creation

Update fields


Add watchers from another field

Update fields

Transition issue

union()

toStringList()

Add a sub-task's summary and key to the description of its parent

Update fields


Set a date field to a future date

Update fields

dateTimeToString()

Record an auditable timestamp of a Compliance Approval

Update fields

dateTimeToString()

Copy field values from epic to issues under it after creation

Update fields Transition issue

epic()

issuesUnderEpic()

filterByStatus()

Set a date field to the current date

Update fields

dateTimeToString()

Assign important issues to the project lead

Update fields


Set the priority to Highest if the 'Infrastructure' component is selected

Update fields


Background priority calculation

Update fields

avg()