Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

How to handle mentions with accountId in a Cloud to Server sync

 
2
1
0

Recent changes in Jira Cloud API related to GDPR (accountId) have impacted the Cloud to Server syncing of comments, in particular how mentions are rendered on server (Cloud - Server sync).

Any ideas on how to approach this new situation? Maybe comments could be sent over with mention markup transformed to plain text with resolved user emails or full names?

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Due to popular demand - here is the approach to convert Jira cloud based mentions to the corresponding display name.


      Challenge


      Hi, I have a Jira Cloud connected to a Zendesk.  Everything works fine, only when a user is mentioned in a comment on the Jira cloud, we see this account id.



      Not very readable - is it.  The challenge is to replace it with the name of the person.



      Approach


      What needs to happen is that in the outgoing sync, the mention needs to be replaced with the display name of the person.


      This can be done with following snippet


      replica.comments = issue.comments.collect { 
          comment -> 
          
          def matcher  = comment.body =~ /\[~accountid:([\w:-]+)\]/
          def newCommentBody = comment.body
          
          matcher.each {
      
              target = nodeHelper.getUser(it[1])?.displayName ?: "Stranger"
              newCommentBody = newCommentBody.replace(it[0],target)
          }
      
          comment.body = newCommentBody
          comment
      }
      
      



      (Make sure to remove the other assignment to replica.comments)


      What this snippet does is 


      • issue.comments.collect will execute the closure on every comment of the source issue
      • The regular expression (/\[~accountid:(\w+)\]/)  will match every mention in a single comment body
      • For each match, the mentioned user is looked up with the getUser function
      • the mention is then replaced with the found displayname



      Note

      • Instead of displayName, one can use email (or a combination)
      • If the user is not found - which can happen due to gdpr settings - the mention will be replaced with 'Stranger' (smile)



      Solution


      In the outgoing sync of the connection on the Jira Cloud side add the code snippet.  Make sure to delete the line 

      replica.comment = issue.comment



      The comment will be sent to the target side  (zendesk, servicenow ...) and processed correctly.


        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Aggelos Paraskevopoulos


        I posted some time ago following article on the Atlassian community.

        https://community.atlassian.com/t5/Agile-articles/How-to-sanitize-mentions-when-synchronizing-issues/ba-p/1141139


        It might be helping to do the conversion from the account-id to the username



        1. Aggelos Paraskevopoulos

          Hi 

          Thanks for the pointer, we'll give it a try. 

          Cheers,
          Aggelos

        CommentAdd your comment...