Recent searches
No recent searches
Attachments in latest_comment placeholder
Posted Mar 03, 2023
Hi,
I'm integrating to our internal system and need attachments to be available too. I've been trying to work on with latest_comment placeholders but seems that if I have multiple attachment on tickets, data in theplaceholder comes like this:
Attachments:\n6245280-1.pdf - https://karkkainen1546515205.zendesk.com/attachments/token/np1tLW78shen2Mx1dFHDBLxuF/?name=6245280-1.pdf6245280-2.pdf - https://karkkainen1546515205.zendesk.com/attachments/token/4x2Ot7BwZfdYTAn1hvG4XehrE/?name=6245280-2.pdf
Seems that attachments are available only in latest_comment_html and latest_comment_formatted. So what I do now in integration layer, I pick up the string after Attachments: text and then parse it to substrings where there is separated attachment name and attachment URL but when there is multiple attachments, there is no characters between first URL and second attachment name. Is there any workaround that I could separate those and format it as <a href=URL>Name</a>? Originally I assumed that there's a linebreak \n but actually it is not there.
Br.
Otto
0
2 comments
Remi
Hello Otto Lindqvist,
Thank you for your post here, I hope you are doing well today!
In order to achieve what you want to do and pass attachments toward an endpoint via JSON, I wouldn't suggest using the following placeholders with your context/scenario :
As indeed, the files / links will be separated by hyphens and no break line, for instance.
I would recommend using the Ticket.Comment object and Comment.Attachments child-node as explained here > Using Liquid markup to customize the formatting and placement of text in comments and email notifications
This placeholders are part of our documentation as well : Standard comment placeholders
And here is the Raw JSON that I received :
This will allow you to pull any property's value in an easier way where you just have to query each node / access each attribute's value within the responded object.
With this placeholder, it will be easier to handle the response as it gives you more granularity coupled with some Liquid Markup condition.
Hope this helps! Have a great rest of your day.
Best regards,
2
Otto Lindqvist
Thanks for the tips. This definately helped me forward. In order to get valid json array, I had to do a quick if statement inside the loop.
Here's the code working for me if someone else is interested in the same topic.
Something that did throw me off, was json editor in Zendesk is noting an error on the line where liquid statement starts but it can be ignored.
2