Return the number of times that a custom field has been changed since the work item was created.
Configuration
Create a Custom smart number field and use the Jira expression parsing mode.
Expression
issue.changelogs
.filter(changelog => changelog.items
.some(item => item.fieldId == 'customfield_nnnnn'))
.length
Please, replace nnnnn with the ID of your custom field in the above expression.
Display as
Number
Formatting style
Default (unformatted)
Details
1. What does the expression do?
This expression counts how many times a specific custom field has been changed in a work item since it was created.
2. Step-by-step breakdown
Let’s break it down:
-
issue.changelogs: This refers to the complete history of changes for the work item. -
.filter(...): This filters the changelogs to only include those where a specific custom field was changed. -
changelog.items: Each changelog contains a list of items, where each item represents a field that was changed in that update. -
.some(item => item.fieldId == 'customfield_nnnnn'): This checks if any item in the changelog refers to the custom field you are interested in (replace nnnnn with your actual custom field ID). -
.length: After filtering, this counts the number of times that the custom field was changed.
3. Examples
Suppose you have a custom field with the ID customfield_12345. The expression would look like:
issue.changelogs
.filter(changelog => changelog.items
.some(item => item.fieldId == 'customfield_12345'))
.length
If the custom field was changed 3 times in the work item’s history, the result would be 3.
4. Real-life use cases
-
Tracking how often a priority or status custom field is updated in a work item.
-
Auditing changes to a custom field, such as “Customer Impact” or “Risk Level,” to see how frequently it’s being reviewed or modified.
-
Reporting or triggering automations when a field has been changed a certain number of times (e.g., flagging work items with frequent changes for further review).