Macro placeholder not work when edit body | Community
Skip to main content

Macro placeholder not work when edit body

  • May 27, 2022
  • 3 replies
  • 0 views

Igor14

Hi...

I'm developing an interface that uses the "Macro/Show Changes to Ticket" and the "Create Ticket" API to create some tickets.
The problem is, in this macro there is some placeholders (like user's name), and I have custom data that I need to change on comment body before send the "Create Ticket" request, but when I do it, the macro placeholder doesn't work anymore. Zendesk doesnt change the placeholder to the user's name when showing the ticket.

I'm using python to do it. I get the json of macro and just

macro['ticket']['comment']['body'] = macro['ticket']['comment']['body'].replace(xxx, yyy)
and the same to the html_body
 
There is something in the replace that I should consider or I just can't change anything in the body before sending it?
 
Thanks

3 replies

Greg29
  • June 3, 2022

Hi Igor! The placeholders need the context of the underlying ticket in order to work, so if you're developing this interface outside of a Zendesk app, you wouldn't be able to capture that placeholder data with the macro's API. The placeholders aren't an API that make a request to Zendesk, they simply pull data contextually. When the ticket creation request is sent to Zendesk, the placeholders will render (if applicable), just not with the API that you're using here.


Igor14
  • Author
  • June 3, 2022

Hi @greg29.

I get that the placeholder just renders when Zendesk is creating the ticket/comment, but my issue is:

When I get the macro changes using the "Show Changes to Ticket" it returns all the changes in the ticket, right? If I get it and sends as an "Update Ticket" put request, it will post the new comment and will replace the placeholder in it. It works just fine.
But when I get the ticket changes, change something else in the body comment (and keeps the place holder intact) and send it a "Create Ticket" post request, it doesn't change the placeholder when rendering it in Zendesk.

I don't know if the problem is changing the comment before sending the request or using the macro changes when creating a new ticket.


Greg29
  • June 6, 2022

Thanks for clarifying that for me. I just tried reproducing this using Postman and I was able to get it to successfully work for me each time, both with a PUT and a POST, using {{ticket.requester.first_name}} as the placeholder. My guess is that the placeholder you're using is not available for ticket creation. Rather than using replace, could you just try to pass the placeholder in as is during a POST and see if it renders? If it does, I would examine the way that replace is either encoding/decoding the characters that it's replacing to ensure that it isn't potentially affecting the placeholder.