Return a list with the previous due dates of the current work item in descending order.
Configuration
Create a Custom smart text field and use the Jira expression parsing mode.
Expression
issue.changelogs.filter(changelog => changelog.items.some(item => item.fieldId
== 'duedate' && item.from != null)).map(changelog => {duedateentry:
changelog.items.filter(item => item.fieldId == 'duedate' )}).map(e => new
CalendarDate(e.duedateentry[0].from).toString()).join(", ")
Details
1. What does the expression do?
This expression returns a list of all previous due dates for the current work item, showing them in descending order (most recent first).
2. Step-by-step breakdown
Let’s break down the expression:
-
issue.changelogs: This accesses the full history of changes for the current work item. -
.filter(...): This keeps only those changelogs where the due date field (fieldId == 'duedate') was changed and where there was a previous value (item.from != null). -
.map(...): For each filtered changelog, it creates an object containing only the items where the due date was changed. -
.map(...): For each of these objects, it takes the previous value of the due date (from), converts it into a date format (CalendarDate), and then into a readable text. -
.join(", "): Finally, it combines all these previous due dates into a single string, separated by commas.
3. Examples
Suppose a work item had its due date changed three times:
-
First due date: 2023-01-01
-
Changed to: 2023-02-01
-
Changed to: 2023-03-01
The expression would return:
2023-01-01, 2023-02-01
(Assuming the current due date is 2023-03-01, the list shows the previous values.)
4. Real-life use cases
-
Audit trail: Track how the due date for a work item has changed over time, which is useful for audits or understanding project delays.
-
Reporting: Display a history of due date changes in a custom field, so team members can quickly see if deadlines have shifted.
-
Process improvement: Identify patterns in deadline changes to improve planning and estimation in future projects.