Replace accountid with person name in the comment


I use the following custom field to get last comment.

name = “Last comment”
data_type = “text”
json_fields = [“comment”]
javascript_code = ‘’’
if (issue.fields.comment && issue.fields.comment.comments && issue.fields.comment.comments.length > 0) {
var lastcomment = issue.fields.comment.comments[issue.fields.comment.comments.length-1];
var commentdate = lastcomment.created.toString().substr(0,19);
issue.fields.customfield_lastcommentt = commentdate + ‘, [’ + + ‘] ’ + lastcomment.body;

How to replace account ids with names for people mentioned in a comment?

Hi @Izzy ,

Unfortunately, your requirement isn’t easy to satisfy in JavaScript or a calculated measure. There are several challenges to overcome. I can lay them out but can’t provide the specific JavaScript code or MDX formula required to address them.

The first problem is retrieving the account IDs. That needs to be extracted with regular expressions.

Once you have the IDs, you can make a REST API call in the JavaScript calculated custom field code with getDocument(). It should retrieve the user display name by their specific accountId from Jira. It could be a loop, running for the number of times there are account Ids in the comment.

In a calculated measure, you can retrieve a user dimension (Assignee, Logged by, Reporter) member whose key matches the accountId with the Replace() function. The replace function will work only once. So, if a comment has more than one user mentioned, the Replace() functions must be nested.

Please see more details about:

Roberts //

Hi @Izzy / @roberts.cacus ,
I have similar requirement where want to display the User full name in last comments. Request you to let me know if this was achieved.