Stored lead specific html in custom field not rendered properly

Franky_Ruyssch2
Level 4

Stored lead specific html in custom field not rendered properly

Hi,

I am trying to store lead specific html in a custom field. The html has been generated from excel, and gets imported by a .csv file.

When I try to load the content of that field by using a token in a guided landing page, the content of that field is rendered as if it was text and not html.

Schermafbeelding 2019-07-31 om 16.28.03.jpg

I have tried this with 2 types of fields : textarea and string, none of them seem to work.

When you inspect the content you see the following :

Schermafbeelding 2019-07-31 om 16.29.48.png

It seems that the content starts and end with double quotes.

When i try to edit this content in the inspector I get the following :

Schermafbeelding 2019-07-31 om 16.31.08.png

How can this be solved?

Thanks

Franky Ruysschaert
5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Stored lead specific html in custom field not rendered properly

Output the token inside an easily findable container, then read it out (using JS) and rewrite it as HTML.

It's not really "improper" to escape the special characters so the text remains text. It's one of the two options, and Marketo can't know which one you want. It's like textContent vs. innerHTML.

Franky_Ruyssch2
Level 4

Re: Stored lead specific html in custom field not rendered properly

Thanks for your reply,

used your input to write a jquery solution:

hiddenFromMarketo = $.parseHTML($('#hiddenFromMarketo').text());
$('#displayFromMarketo').html( hiddenFromMarketo );

Franky Ruysschaert
SanfordWhiteman
Level 10 - Community Moderator

Re: Stored lead specific html in custom field not rendered properly

OK...  but that's slower and has unnecessary dependencies. This (like most things in 2019) is a job for vanilla JS like that in my blog post.

Andrew_Holstei1
Level 2

Re: Stored lead specific html in custom field not rendered properly

Thanks Sanford Whiteman‌ your article was very helpful. Is there a way to do this for an email? Am new to JS so please excuse me if this is a rookie question!

SanfordWhiteman
Level 10 - Community Moderator

Re: Stored lead specific html in custom field not rendered properly

Well, there's no JS in emails, period.

If you want to output HTML code (not HTML-encoded text) this sounds like my last blog post: https://nation.marketo.com/community/product_and_support/blog/2019/09/17/even-when-velocity-isn-t-do...