Expand my Community achievements bar.

Join expert-led sessions on Real-Time CDP & Journey Optimizer designed to boost your impact.

Unable to access JSON offer into Email template for rendering

Avatar

Level 5

Trying to access the JSON offer in the email template for custom rendering format. The offers are stored as JSON. (Saved the JSON into HTML placemnt)

 

Trying ways to access JSON as an object in an email template to custom render. 

 

<% let selectedOffer = offer.html['dps:offer-placement:12324324']['sps:offer-activity:32423423'].content %>

{{selectedOffer}}

 

It throws an error when rendering JSON. Any suggestions would help.

5 Replies

Avatar

Level 7

Avatar

Employee Advisor

You can use the following snippet as an example 

{{{offer.html.[dps:offer-placement:19d91803ed87a1a0].[dps:offer-activity:1a9a487ec2b1a708].content}}}

Avatar

Level 5

It'll directly renders the JSON, but wanna capture in a variable and handle with custom rendering.

 

<% let contentValJSON = offer.html.['dps:offer-placement:1a9ce5b1668c0f58'].['dps:offer-activity:1a9ce7b236595802'].content %>
 
Unable to capture JSON into a variable
{{contentValJSON}}

Avatar

Employee Advisor

Try using it on the following lines 

{{#with offer.html.[dps:offer-placement:1a9ce5b1668c0f58].[dps:offer-activity:1a9ce7b236595802].content as |val|}}
   {%= val %}
{{/with}}

 

Avatar

Level 5

This prints the val but what we are trying to do it that it prints offer details with diffrent variation based on profile.

 

{{#with offer.html.[dps:offer-placement:1a9ce5b1668c0f58].[dps:offer-activity:1a9ce7b236595802].content as |val|}}
   OfferID: {{val.offerDiscountVal}}
   Offer Title: {{val.offerRegion}}
{{/with}}
 
But it's unable to find JSON attributes offerDiscountVal and offerRegion KotiSyamala_0-1746476075794.png