xl8bot
1
Originally asked by Michiel Singh on 09 August 2023 (original question)
Hi all
I have been trying to get a script working where we replace a mention in Jira to the displayname of the user (could also be email). However, based on the info found online (such as https://community.atlassian.com/t5/Agile-articles/How-to-sanitize-mentions-when-synchronizing-issues/ba-p/1141139, How to handle mentions with accountId in a Cloud to Server sync (old community)) I havent been able to get this to work. Maybe this info is outdated or…
Anyone has this working in a currently running script for Jira Cloud? Working examples would be highly appreciated!
Kind regards
Michiel
xl8bot
2
Answer by Ola Timpson on 09 August 2023
I do this! My script only syncs the latest comment, but the replacement works.
This is in outgoing on the Jira side:
if (issue.comments.findAll { comment -> comment.author.displayName != "Exalate" }) {
latestTime = issue.comments.findAll { comment -> comment.author.displayName != "Exalate" }.max { it.created }.created
lcomment = issue.comments.find { comment -> comment.created == latestTime && comment.author.displayName != "Exalate" }
def matcher = lcomment.body =~ /\[~accountid:([\w:-]+)\]/
def newCommentBody = lcomment.body
matcher.each {
target = '@' + nodeHelper.getUser(it[1])?.displayName
newCommentBody = newCommentBody.replace(it[0],target)
}
lcomment.body = newCommentBody
replica.latestComment = lcomment
}
xl8bot
3
Answer by Michiel Singh on 09 August 2023
Ola Timpson Adapted your scripts to my needs and it now works. Big thanks for sharing!
Comments:
Ola Timpson commented on 09 August 2023
Glad to hear it!
xl8bot
Closed
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.