How to add new lines to comment body in ADO

Originally asked by Joel Maanmies on 29 September 2022 (original question)


Hello, anyone knows how to get new lines in the comment body in ADO? I’ve added new lines but the comment.body still gets printed on the same line as comment.author.email.

Example of outgoing and incoming

Outgoing on ServiceNow side

replica.comments = customerCase.comments

Incoming on Azure side
if (comment.internal) {

comment.body \= convertedDate \+ " \- " \+  
"Internal comment by " \+  
comment.author.email \+ " \-\\n" \+  
comment.body \+ "\\n"

}


Comments:

Support commented on 01 October 2022

Hi Joel Maanmies,

We have tried to reproduce your scenario, and we would like to discard this can be a potential bug, could you please raise a support issue case to investigate further? Please check the documentation below:

https://docs.idalko.com/exalate/x/joHk

Kind regards.

Answer by M. Ashar Iqbal on 10 October 2022

Hi Joel Maanmies , as communicated via Support ticket, the below solution has worked.

We’ve replaced “\n” with <br/> because in ADO ‘comment’ is type of HTML so <br/> will resolve a problem.

Incoming Sync into Azure DevOps:

//def targetUser = nodeHelper.getUserByEmail(comment.author.email, workItem.projectKey)
    if (comment.internal) {
            //comment.executor = targetUser
            comment.body =
            "Internal comment by " +
            comment.author.email + "<br/>" +
            comment.body + "<br/>"
        } else {
            comment.body =
            "Customer visible comment by " +
            comment.author.email + "<br/>" +
            comment.body + "<br/>"
        }
    }

Thank you,

Ashar