Originally asked by Christos Katsivas on 04 June 2021 (original question)
Hi team,
I have an integration between Jira and Zendesk. I would like to cut the comment when it has more than 65535 characters. I have created a script and its works fine but the comment author appears 2 times. How i can fix this?
You can find attached the script and the comment.
//Comments
issue.comments = commentHelper.mergeComments(
issue,
replica,
{ comment ->
if (comment.internal) {
comment.body = "Internal " + "comment from Zendesk: \n" + "[" + comment.author.displayName +
"| mailto:" + comment.author.email + "]" +
" commented: \n" + comment.body
}
else {
comment.body = "Public "+"comment from Zendesk: \n" +
"[" + comment.author.displayName +
"| mailto:" + comment.author.email + "]" +
" commented: \n" +comment.body
}
def maxCommentLength = 65535
def template = "[
{0}
|mailto:
{1}
]" +
" commented: \n" +
"'
{quote'}\n" +
"{2};\n" +
"'{quote'}
\n"
def renderedWithoutBody = java.text.MessageFormat.format(
template,
comment.author.displayName,
comment.author.email,
""
)
def allowedLength = maxCommentLength
renderedWithoutBody.length()
comment.body = java.text.MessageFormat.format(
template,
comment.author.displayName,
comment.author.email,
comment.body.take(allowedLength)
)
comment;
}
)
Thank you.
Comments:
Francis Martens (Exalate) commented on 04 June 2021
The code is hard to read - can you reformat it?
Christos Katsivas commented on 07 June 2021
Hi Francis,
Yes I confirm. I found the problem and its works fine.
Thank you.