Questions for Confluence license has expired.

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

How to custom format a public comment

 
1
0
-1

I want to merge two properties for comments in Jira Service Management.

I need them to be at the same time:

1) public

2) formatted

I can achieve these objectives separately but not together. I could not find such a use case in the Community. Can anyone merge the snippets for me?


//Synchronize comments as public
issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = false})

//Synchronize comments and format it diplaying an author name
issue.comments = commentHelper.mergeComments(issue, replica,
                       {
                       comment ->
                       comment.body =
                          comment.author.displayName +
                                  " commented: \n" +
                          "{quote}\n" +
                          comment.body + ";\n" +
                          "{quote}\n"
                       })
    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      This is the solution to this use case - tested and working.

      issue.comments = commentHelper.mergeComments(issue, replica,
              {
              //Sync the comment and format the display of an author name
      		comment ->
              comment.body =
              comment.author.displayName +
                  " commented: \n" +
                  "{quote}\n" +
                  comment.body + ";\n" +
                  "{quote}\n"
              //Make the comment public on Service Desk 
      			comment.internal = false
      			comment
      		})

      As a result, you get a nicely formatted public comment, which is visible on the portal.

      This overcomes the limitation of the Jira Service Management, because you can allow a direct conversation between your Dev team with the JSM Customer.

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

        Hi Bogdan,


        I premise you are using Jira on-prem since Jira Cloud does not support mergeComments with custom formatting

        Can you try 


        issue.comments = commentHelper.mergeComments(issue, replica, {
        	comment ->
        	comment.body =
        		comment.author.displayName + 
        		" commented: \n" +
                "{quote}\n" +
        		comment.body + ";\n" +
        		"{quote}\n"
        
        	//https://community.atlassian.com/t5/Jira-Service-Management/Create-Internal-Comment-using-REST-API-for-Jira-Service-Desk/qaq-p/857385
        	comment.public = false
        })


        or 

        issue.comments = commentHelper.mergeComments(issue, replica, {
        	comment ->
        	comment.body =
        		comment.author.displayName + 
        		" commented: \n" +
                "{quote}\n" +
        		comment.body + ";\n" +
        		"{quote}\n"
        }) {
          	it.internal = false 
        }

        Reference: https://docs.idalko.com/exalate/pages/viewpage.action?pageId=6226071

        1. Bogdan Gorka

          Hi Sim Hua Soon 

          You were close but both solutions caused the sync to have an error. See the solution below that my good colleague developed.

        2. Bogdan Gorka

          And thank you Sim Hua Soon for the answer because it helped me to get closer to the solution

        CommentAdd your comment...