1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
825 views
by brandon-w-8204 (34.1k points)
I want to use a JSON template with evaluateTemplate and I keep getting a blank result. What is the syntax to use evaluateTemplate with a JSON template?

1 Answer

0 votes

Because JSON uses brackets as part of the syntax you have to escape the node tags as well as specify isJSON as true on the evaluateTemplate.

Here is sample JSON template.

{
  "hardCodedValue": "value",
  "messageCacheValue": "/*{mc:testValue}*/"
}

Here is sample code for the evaluate template

//Add a value to the messageCache for evaluateTemplate to replace
messageCache.setValue('testValue', 'someValue');
//Get system variable 'jsonTemplate' and evaluate the nodetag /*{mc:testValue}*/
var json = qie.evaluateTemplate(qie.getVariable('jsonTemplate'), null, null, true);
//set the message to the evaluated value.
message.setNode('/', qie.parseJSONString(json));

 

by brandon-w-8204 (34.1k points)
...