Expand my Community achievements bar.

Join our product experts for a live Ask Me Anything on November 12th at 8 AM PT about Experiences & Efficiency with AEP Agent Orchestrator & How Agentic AI is Fueling Smarter Testing and Growth!

Contextual field with Helper function

Avatar

Level 1

I am facing some error when adding contextual field in function while trying to do some personalization in email with in a journey. 

Any idea on what could be the resolution for this ?

7 Replies

Avatar

Employee Advisor

Kindly use back ticks for the event Id 

Example -> context.journey.events.`1792665356`........

Avatar

Level 1

don't think that is correct syntax.

 

 

 

Avatar

Employee Advisor

It's a different error now and the function signature is not being matched. You are using an array object where as the function expects a string. You can validate it on the following lines

Example 
{{#each context.journey.events.`eventId`._tenant.npoEvent.traject as |s|}}
        {%= replaceAll(s.discountedPrice,"([0-9]+\\.[0-9]{2}).*","$1") %} 
{{/each}} 

 

Avatar

Level 1
Ok some confusion, will explain again. I need to use below syntax in email. i am not able to pass context field as replaceAll expecting string. So original question how do i pass context field here
 
{%= replaceAll(context.journey.events.923737463.Event.test.totalPrice, "([0-9]+\\.[0-9]{2}).*", "$1") %}

Avatar

Employee Advisor

Use it on the following lines as mentioned previously as traject is an array object and it needs to be iterated over. eventId needs to have backticks.

Example 
{{#each context.journey.events.`eventId`._tenant.npoEvent.traject as |s|}}
        {%= replaceAll(s.discountedPrice,"([0-9]+\\.[0-9]{2}).*","$1") %} 
{{/each}} 

 

Avatar

Employee Advisor

@riyaA 

Can you Reference contextual fields directly?

{{context.journey.events.923737463.LEAD_88_8_05.discountedPrice}}

 

Avatar

Administrator

Hi @riyaA,

Were you able to resolve this query with the given solution or was this something you were able to figure out on your own or do you still need help here? Do let us know.

Thanks!



Sukrity Wadhwa