Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to add a personalized field dynamically during delivery run-time?

Avatar

Level 6

Hello Folks,

I have a campaign workflow with an delivery in which content is coming from AEM with a placeholder <%= targetData.url %>. This will get value from the additional data that i have added in Query whenever workflow runs. But i have got the requirement to trigger the delivery directly from Delivery template instead of going with a workflow. When i am doing this, i am facing an error targetData not found, since there is no previous activity to get the data just like how it happens in case of workflow.

Is there any way to replace such field with let's say i can directly fetch this field in template from the blip icon Recipients -> URL. After selecting this i am getting a personalized field <%= recipient.url %> courtesy due to target mapping. If so, How can i replace <%= targetData.url %> with <%= recipient.url %> during run-time, can i use a typology rule for it? Please provide pointers.

PS: I understood that we can change the placeholder directly in AEM template to <%= recipient.url %> but we are not supposed to do that, instead we are trying possibilities from Campaign itself

Regards,

Sri Bhargav

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hello Sri,

I put this code into a typology rule and it seems to work properly:

// HTML version

var regExp = new RegExp('targetData', 'gi');

var existingHtml = delivery.content.html.source;

var newHtml = existingHtml.replace(regExp, 'recipient');

delivery.content.html.source = newHtml;

Best Regards,

Geoffrey LE GAC.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 4

Hello Sri,

I put this code into a typology rule and it seems to work properly:

// HTML version

var regExp = new RegExp('targetData', 'gi');

var existingHtml = delivery.content.html.source;

var newHtml = existingHtml.replace(regExp, 'recipient');

delivery.content.html.source = newHtml;

Best Regards,

Geoffrey LE GAC.

Avatar

Level 6

Thank You Geoffrey,

Will try this Approach, but can you please let me know if it still works, when there no such word found. Let's say i am searching for word target and if found replace it with word recipient. What if not found? Will it throw any error or i can able to configure the rule in such a way that Don't throw error, instead log warning.

Regards,

Sri Bhargav

Avatar

Level 6

It worked, i tried negative case like:

1. When word to replace is not found - No error thrown, i chosen Level as Info, instead of Error/Warning ​in the typology rule.

Thanks,

Sri Bhargav