This template displays the number of times that the Resolution field was set with the resolution “Rejected” in the current work item.
Configuration
To use the Count work item rejections template, simply select it from the template grid. Filter by Status to find it faster.
Parameters
This template does not require any additional parameter configuration.
Expert mode
If you switch to Expert mode you can see the formula field in the Expression Parser. You can now tweak the expression to create a custom formula field based on this template.
Expression
Jira expression:
issue.changelogs.filter(changelog => changelog.items.some(item => item.fieldId == 'resolution' && item.toString == 'Rejected')).length
In case you have other statuses and resolutions, feel free to change these arguments: " item.fieldId == 'resolution' && item.toString == 'Rejected'"
Display as
Number
Formatting style
Default (unformatted)
Description
1. What does the expression do?
This expression counts how many times the Resolution field was set to "Rejected" in the current work item. In other words, it tells you how many times a work item has been marked as rejected throughout its history.
2. Step-by-step breakdown
Let's break it down:
-
issue.changelogs: This refers to the complete change history (changelogs) of the current work item. -
.filter(changelog => ...): This filters the changelog entries, keeping only those that meet a certain condition. -
changelog.items: Each changelog entry can contain multiple items, each representing a field that was changed. -
.some(item => ...): This checks if at least one item in the changelog entry matches the condition. -
item.fieldId == 'resolution': This checks if the changed field is the "Resolution" field. -
item.toString == 'Rejected': This checks if the new value set for the Resolution field is "Rejected". -
The filter keeps only those changelog entries where the Resolution field was set to "Rejected".
-
.length: Finally, this counts the number of changelog entries that matched the condition, giving you the total number of times the work item was rejected.
3. Examples
Suppose a work item has the following history for its Resolution field:
-
First, it was set to "Rejected".
-
Then, it was cleared.
-
Later, it was changed to "Rejected".
-
Finally, it was set to "Done".
This expression would count 2, because the Resolution field was set to "Rejected" two times in the work item's history.
4. Real-life use cases
-
Quality control: Track how many times a work item has been rejected, which can help identify problematic items or processes.
-
Process improvement: Analyze trends in rejections to improve workflows or identify training needs.
-
Reporting: Display the number of rejections on dashboards or reports for better visibility into work item status changes.