Is there a way to modify attachement comment in Zendesk

Originally asked by Sándor Jankovics on 13 January 2022 (original question)


Hi. I have a connection for Zendesk with Jira using exalate.

I would like to customize the comment being added to the Zendesk when a new attachment arrives.

Right now I use the code for attachment sync provided here Attachment in internal Zendesk comment ? (old community)

replica.addedAttachments = replica.addedAttachments.collect{it.internal = true; it}
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)

When a new attachment arives the code adds this comment along with the attachment

However I would like to write in such case other text.

Is there a way to do it?

Thanks

Sanyi


[Failed to download attachment: attachment_42830653_image2022-1-13_13-36-41.png. Error: 404 Client Error: for url: https://community.exalate.com/download/attachments/42830646/image2022-1-13_13-36-41.png?version=1&modificationDate=1642077401799&api=v2]

Answer by Ariel Aguilar on 14 January 2022

Hi Sanyi,

The headline comment added that comes with the attachment, it cannot be modified at the moment. But did you try the following?

if (replica.addedComments && !replica.addedAttachments.empty)  { 
issue.comments = commentHelper.mergeComments(issue, replica,                     
                    {
                       comment ->
                       comment.body = "Attachment received"
                    }
)
}
issue.comments += replica.addedComments
} 
replica.addedAttachments = replica.addedAttachments.collect{it.internal = true; it}
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)

Kind regards,

Ariel