Gå till huvudinnehåll

I'm having trouble getting variables in custom phrases to work - Kunskapsbas / Using Deskpro / Admin - Deskpro Support

I'm having trouble getting variables in custom phrases to work

Författarlista

Question:

I've created a custom phrase, but when I include a template variable in it, it is not replaced with the value. The variable works fine when I put it directly in the template. What's the problem?

 

Answer:

You can't include the standard template variables in a custom phrase. Instead, you use a special format when you include the phrase in the template.

Say you want your custom phrase to include the name of the assigned agent. In the template you'd use this variable:

{{ ticket.agent.display_name }}

 

But in the custom phrase you would include a variable like this:

{{agent-name}}

 

The exact name doesn't matter - this is a variable specific to the custom phrase, that you will reference from the template. Note that you don't put a space between the name and the double-curly brackets as you do with the standard template variables.

Then in the template you would put this:

 

{{ phrase('custom.ticket.auto-notification-agent', { agent-name:   ticket.agent.display_name }) }} 

 

This means that when an email is sent with the template, the value of ticket.agent.display_name is inserted into the custom phrase where you put {{agent-name}}. 

Hjälpfull Oanvändbar

63 av 113 personer tyckte att sidan var användbar

Posta en kommentar

Logga in eller registrera dig för att lämna en kommentar.

Behöver du en påminnelse om ditt lösenord?