Javascript code being escaped in HTML templated

Avatar

Avatar
Validate 1
Level 1
hugol_vallejo
Level 1

Likes

3 likes

Total Posts

13 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
hugol_vallejo
Level 1

Likes

3 likes

Total Posts

13 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
hugol_vallejo
Level 1

13-12-2020

Hi There

 

I have a requirement where a I need to add some html blocks to the email template based on the value of some attributes that are populated in the delivery workflow. I have a simple javascript code in the HTML template using an AND condition (&&) but the ampersands are being escaped after saving the template and they are converted into &

 

Original code snippet:

<tbody><!-- BEGIN DYNAMIC CONTENT BLOCKS --> <%if(targetData.recommendations1.ocidLink != '' && targetData.recommendations2.ocidLink != '') { %>

 

After saving the template and re-opening it:

<tbody><!-- BEGIN DYNAMIC CONTENT BLOCKS --> <%if(targetData.recommendations1.ocidLink != '' &amp;&amp; targetData.recommendations2.ocidLink != '') { %>

 

When I run the workflow with that template the delivery fails as the code snippet is broken due to the && code being escaped.

 

I also tried to embed the code in a <script> tag, but upon saving the template and close it Adobe Campaign deletes the <script> tag and everything that was inside it. After re-opening the template I can see that the <script> tag  is gone and everything in it was deleted.

 

Does someone have any suggestions to make this work?

 

Thanks!

Hugo

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 1
hugol_vallejo
Level 1

Likes

3 likes

Total Posts

13 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
hugol_vallejo
Level 1

Likes

3 likes

Total Posts

13 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
hugol_vallejo
Level 1

05-01-2021

Thanks to everyone who replied. I was on leave and could not reply back until now.

 

Since it was an urgent request at the time by our stakeholders I had to make it work on the same day as that was my last day before going into leave. So I moved the logic to the workflow itself as that was the quickest way to solve it at the time.  I did not have time to try out the suggestions before going into leave unfortunately.

 

So instead of using the AND ($$) condition in the email template I just moved the logic to the workflow and it is begin running fine since, however two different templates are used for each output of the workflow depending on whether the AND condition is true or false. It is a bit cumbersome but it worked.

 

I will provide the error details with the original approach once I had the time to check again

 

Thanks

Hugo

Answers (3)

Answers (3)

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

168 likes

Total Posts

928 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

168 likes

Total Posts

928 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

05-01-2021

Hi @hugol_vallejo,

Were you able to resolve this query or do you still need more help here? Do let us know.

Thanks!

Avatar

Avatar
Validate 1
Level 2
amritakedia_epsilon
Level 2

Likes

5 likes

Total Posts

50 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 5
View profile

Avatar
Validate 1
Level 2
amritakedia_epsilon
Level 2

Likes

5 likes

Total Posts

50 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 5
View profile
amritakedia_epsilon
Level 2

18-12-2020

Pls try this:

 

<tbody><!-- BEGIN DYNAMIC CONTENT BLOCKS -->

<%if(targetData.recommendations1.ocidLink != "" && targetData.recommendations2.ocidLink != "") { %>

Avatar

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile
Milan_Vucetic
MVP

14-12-2020

Hi @hugol_vallejo 

First way is not wrong at all. Adobe needs to convert this inside of delivery html and it should work fine.

Could you, please, provide an error from the workflow logs as I think that something else is issue here.

Regards,

Milan