Questions for Confluence license has expired.

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

Handle Description Mentions from JiraCloud to Jira server

 
2
1
0

Hi, 


We have few issues where description has users mentions in Jira Cloud something like this


but [~accountid:5d1463a784d7dc0c52fda8f4] reopened it....


Jira Cloud : but Username reopened it....

Jira Server : but [~accountid:5d1463a784d7dc0c52fda8f4] reopened it....


How to handle user mentions in the script to convert it to Displayname in Jira Server

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      I have modified the code slightly and it worked.


      def matcher_des  = issue.description =~ /\[~accountid:([\w:-]+)\]/
      def description = issue.description
      matcher_des.each {
         target = nodeHelper.getUser(it[1])?.displayName
        description = description.replace(it[0], target)
      }
      replica.description = description

        CommentAdd your comment...
      1.  
        2
        1
        0

        Hi Vinay,
        This article might help you:

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

        you could replace every mention sent from cloud with email:


        /*
        ** This code snippet illustrates how mentions can be replaced with the actual name of the mentionee
        ** Use this in a data filter
        */
        
        
        replica.comments       = issue.comments.collect {
                      comment ->
                      
        
                      def matcher  = comment.body =~ /\[~(\w+)\]/
                      def newCommentBody = comment.body
        
                      matcher.each {
                          target = "[~$nodeHelper.getUser(it[1])?.email]"
                          newCommentBody = newCommentBody.replace(it[0], target)
                      }
        
                      comment.body = newCommentBody
                      comment
        }



        And then use similar logic on server to lookup a user using email
        Please, let me know if this helps

        1. Vinay

          Mariia Onyshchenko , I have seen that article,  but I need the script for description user mentions not for comments!

        2. Ariel Aguilar

          Hi Vinay,

          For description, you can try adding this to the Outgoing script:

          def matcher  = issue.description =~ /\[~(\w+)\]/
          def description = issue.description
          matcher.each {
             target = "[~$nodeHelper.getUser(it[1])?.email]"
            description = description.replace(it[0], target)
          }
          replica.description = description

          Let me know if this works for you.

          Kind regards,

          Ariel

        CommentAdd your comment...