Dot Syntax In Reply Templates

Hi,

I am not sure if this should be included under "Technical" or "Developer", so I will add this to both. 

I am trying to create a reply template that shows extended values from a ticket.  See below.

All these variable names are taken by clicking the Spanner on the Details tab of the ticket.

The first two simple variables work.

[[ticket.id]]
[[ticket.title]]

But any variables that are more complex, as below, do not work in the reply template, despite these working on the ticket details screen.

[[ticket.x_prd_serialid.x_crminstallerid.name]]
[[ticket.x_prd_serialid.x_productcode]]
[[ticket.x_prd_serialid]]

[[ticket.cust_id.direct/formattedNumber]]
[[ticket.cust_id.mobile/formattedNumber]]
[[ticket.cust_id.emailAddress]]

How do I include template variable such as these in the reply templates?

Many thanks,

Trevor

RE: Dot Syntax In Reply Templates

Hi,

Parser does not contain all variables or very "deep" dot syntax, if you have such needs it can be accomplished with CRMScript and passing variables to Parser manually.
Which variables that are available will vary with context, if you wish to see those available to you in your context you can add [[PARSER_TREE]] to your reply template.

By: Michel Krohn-Dale 24 Aug 2020

RE: Dot Syntax In Reply Templates

Hi Michel,

Thanks for this.  Can you please advise the piece of code to pass a value through to a parser variable.

Thanks,

Trevor

By: Trevor Sharp 24 Aug 2020

RE: Dot Syntax In Reply Templates

Hi,

Lets say you create a CRMScript with this content:

Integer rtId = 20;
Integer ticketId = 20;

ReplyTemplate rt;
rt.load(rtId);
Parser p;
Ticket ticket;
ticket.load(ticketId);
ticket.toParser(p);

p.setVariable("Amount", "100000");
p.setVariable("SaleType", "New Sale");

Email email;
email.setValue("to", "someemail@email.com");
email.setValue("from", "myemail@company.com");
email.setValue("subject", p.parseString(rt.getSubject(0)));
email.setValue("bodyHtml", p.parseString(rt.getHtmlBody(0)));
email.send();

And you have reply template looking like this;

Request [[ticket.id]] with title: [[ticket.title]] has Amount [[Amount]] with SaleType [[SaleType]]

It should replace template variables with values from script (some manually added and some from Ticket)

By: Michel Krohn-Dale 24 Aug 2020

RE: Dot Syntax In Reply Templates

Hi Michel,

That is perfect, thanks.  I will give this a go.

Thanks again,

Trevor

By: Trevor Sharp 27 Aug 2020