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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

getElementById

andreab24032044
Level 2
Level 2

Hello,

I am trying to use the document.getElementByID method and it is throwing an error while evaluating the script

Capture.JPG

Is there an alternative Adobe Campaign method that would work the same way?

Thanks!

1 Accepted Solution
MarcelSzimonisz
Correct answer by
Community Advisor
Community Advisor

Hello, if  are you trying to change email content before personalization you can use regular expressions  eg.

var html = delivery.content.html.source;

var regex = new RegExp("</body></html>","ig");

var regex2 = newRegExp("<div id=\"your_id\">(.*?)<\/div>","ig");

html.replace(regex,'add_your_html');

html.replace(regex2,'add_your_html');

delivery.content.html.source = html;

OR you can try to amend html with  XML  E4X extension look it up in jsapi (have not tried).

Marcel

View solution in original post

3 Replies
kapilsharma0101
Level 4
Level 4

Hi,


Can you please elaborate a little bit about the issue, and what exactly you are trying to achieve ?

MarcelSzimonisz
Correct answer by
Community Advisor
Community Advisor

Hello, if  are you trying to change email content before personalization you can use regular expressions  eg.

var html = delivery.content.html.source;

var regex = new RegExp("</body></html>","ig");

var regex2 = newRegExp("<div id=\"your_id\">(.*?)<\/div>","ig");

html.replace(regex,'add_your_html');

html.replace(regex2,'add_your_html');

delivery.content.html.source = html;

OR you can try to amend html with  XML  E4X extension look it up in jsapi (have not tried).

Marcel

View solution in original post

andreab24032044
Level 2
Level 2

Many thanks, I ended up following a very similar approach