This template displays the name of the previous assignee in the current work item.
If the Assignee field was empty or never had a value before, “None” will be displayed.
Configuration
To use the Previous assignee template, simply select it from the template grid. Filter by Assignee 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:
let assignees= issue.changelogs.map(i=>i.items).flatten().filter(i=>i.field=="assignee");
assignees.length>0 ?
assignees.map(a=>a.fromString)[0] == null ?
""
:assignees.map(a=>a.fromString)[0]
: ""
Details
1. What does the expression do?
This expression retrieves the name of the previous assignee for the current work item. If the work item has never had an assignee, it displays "None".
2. Step-by-step breakdown
Let’s break it down:
-
issue.changelogs: This gets the full history of changes made to the work item. -
.map(i => i.items): For each change, it gets the list of fields that were changed. -
.flatten(): Combines all those lists into a single list. -
.filter(i => i.field == "assignee"): Keeps only the changes where the "assignee" field was changed. -
let assignees = ...: Stores this filtered list in a variable calledassignees.
Now, the next part checks if there are any assignee changes:
-
assignees.length > 0 ? ... : "": If there are any assignee changes, do the following; otherwise, return an empty string. -
assignees.map(a => a.fromString)[0]: Gets the previous value of the assignee from the first change in the list (i.e., the most recent change). -
== null ? "" : ...: If the previous value is null (meaning the field was before empty), return an empty string; otherwise, return the previous assignee's name.
3. Examples
-
If a work item was assigned from Alice to Bob, the expression will return "Alice" (the previous assignee).
-
If a work item was never assigned to anyone, the expression will return an empty string (or "None" in the template).
-
If the assignee was changed multiple times, it always returns the most recent previous assignee.
4. Real-life use cases
-
Audit trail: Quickly see who was responsible for a work item before the current assignee.
-
Reporting: Create reports or dashboards showing how often work items change hands.