Assignment history is extremely important to my customer. For some obvious transparency and traceability reasons this is something they want to be able to track. In the past, I've created various "position/title" user picker fields, but that doesn't quite fit the desired functionality.
Then I saw this in the Adaptavist Library: Show Assignee History on Issue Details Page https://library.adaptavist.com/entity/show-assignee-history-on-issue-details-page
I wish I had a screenshot to show what the ScriptRunner script fragment produces, but this is what it resembles (Credit: PowerPoint Magic):
This script is great! My customer LOVES the simplistic solution.
The down-side to having the script fragment (for my customer) is the following:
It's got me wanting to aggregate this in a scripted field...
Problem is...
I'm open to suggestions, but I am limited within my strict environment. Buying a new add-on(s) is not an option till next FY quarter (if then).
---
I have a feeling, someone in the community has this same ask/question, and I think it could be accomplished in several ways. I'm about to go down this rabbit-hole, but if anyone has suggestions or has already come up with this solution, I'd be extremely grateful!
@Zita Bagi, That is the first of my listed concerns above. The list generated from the script-fragment does not back-date. Where you set the limit in the code is shown in the image attached below, but it only captures assignee history from the moment you apply the script-fragment. I assume you can change the limit to include more than 5, and I have not tested it to see how many can be listed before the list becomes excessive.
As far as to how I did it in my original post... I do not have a Jira environment on this network, so I created the reference image out of various images I found by performing a internet search and splicing them together (via PowerPoint) to resemble what it looks like on my production environment.
Thanks for the explanation, I understand the question better now.
I was trying to rewrite the table part with StringBuilder builder=new StringBuilder() based on what I found in
https://community.atlassian.com/t5/Jira-questions/Script-Runner-Last-Login-Date/qaq-p/311789/page/0
but I'm getting an error for the 29th line: expecting: ':', found: ')' - This is the last ) in the line, I guess.
Do you know how the table could be put into html, or any ideas? My idea was to try to append the new list elements so that the old once wouldn't disappear.
import com.atlassian.jira.avatar.AvatarService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.Issue
import groovy.xml.MarkupBuilder
import java.time.format.DateTimeFormatter
import static com.atlassian.jira.issue.IssueFieldConstants.ASSIGNEE
// the upper limited on the assignees to be displayed
final int historyDepth = 50
def issue = context.issue as Issue
def counter = 0
def baseUrl = ComponentAccessor.applicationProperties.getString(APKeys.JIRA_BASEURL)
def avatarService = ComponentAccessor.getComponent(AvatarService)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
new MarkupBuilder(writer).table {
ComponentAccessor.changeHistoryManager.getChangeHistories(issue).reverseEach {
def changeItems = it.changeItems
if (changeItems.field.first() == ASSIGNEE && changeItems.newstring.first() && counter < historyDepth) {
def user = ComponentAccessor.userManager.getUserByName(changeItems.newvalue[0] as String)
def format = DateTimeFormatter.ofPattern("dd/MMM/yyyy")
def date = it.timePerformed.toLocalDateTime().toLocalDate()
StringBuilder builder=new StringBuilder()
builder.append('<tr><td style="width: 90px;">'+date.format(format)+'</td><td class="jira-user-name user-hover jira-user-avatar jira-user-avatar-small" rel="admin" id="project-vignette_admin" style="margin: 1px 0px 1px 0px; height: 24px;" href="'+$baseUrl/secure/ViewProfile.jspa?name=$user.name+'"><span class="aui-avatar aui-avatar-small"><span class="aui-avatar-inner"><img src="'+avatarService.getAvatarURL(loggedInUser, user)+'"></span></span></td><td>'+user.displayName+'</td></tr>')
/*tr {
td(
style: "width: 90px;", date.format(format)
)
td(
class: "jira-user-name user-hover jira-user-avatar jira-user-avatar-small",
rel : "admin", "id": "project-vignette_admin",
style: "margin: 1px 0px 1px 0px; height: 24px;",
href : "$baseUrl/secure/ViewProfile.jspa?name=$user.name"
) {
span(
class: "aui-avatar aui-avatar-small"
) {
span(
class: "aui-avatar-inner"
) {
img(
src: avatarService.getAvatarURL(loggedInUser, user),
alt: user.name
)
}
}
}
td(
user.displayName
)
}*/
}
counter++
}
}
Also, I changed the final int historyDepth = 50 part and that didn't change anything.