Recently some of my AMPScript calls raised errors which they did not do before.

I call most of my AMPScripts inside a variety of different blocks (HTMl, Text, Image, ...) with the function ContentBlockByKey like this


When i recently opened one of my template emails some of those functions crashed because " were interepreted as " which makes the function raise an error: Object reference not set to an instance of an object.

I did not touch the working template before, but when i did further investigation, i saw the following:

When you touch an TextBlock with working AMPScript inside it (historicly inserted in the HTML-Editor of the Content Tab, when you create an email) it automaticly opens the Content View instead of the HTML Editor and saves itwhen you click on Done Editing. The result is that the " become " and the AMPScript fails (obviously).

So my questions would be:

  1. Can i do something to prevent this? [users without programmatic knowledge may not understand this]
  2. Wouldn't it be better that the content inside AMP-Script Blocks %%[ ]%% or %%= =%% or %% %% will not be interpreted at all?

Unrelated question: How can you insert a string containing " into a variable?

Thank you very much

2 Answers 2


Just had this issue come up today. If the ampscript is visible in the WSIWYG, it seems to convert it to html and break the ampscript. We were able to sort this out by hiding the Ampscript blocks.


<!--%%=ContentBlockbyKey("AMPScriptBlock")=%% -->

Using HTML comments tags on the Ampscript will hide it, but not 'comment out" its functionality

  • I found one comment from Adam Spriggs containing this matter. Do you have any insight on this @Data_Kid Adam Spriggs: Also, one caution about using <!-- --> to hide AMPScript...it will cause problems in the text version of your email. related link: link Feb 12, 2018 at 7:19
  • I have not found this to be an issue and given that the emails had to go out on Friday, was an acceptable risk
    – 0xsegfault
    Feb 12, 2018 at 10:48

I talked to support about this earlier today. This is apparently a known issue in the freeform and text blocks in content builder. It's converting things to HTML encoding. The temporary workaround they suggested was to replace freeform and text blocks with HTML blocks.

I tried it and updated my journeys and emails and haven't had any further problems. Support did tell me they're working on pushing a hot fix some time next week, but no ETA yet.

I haven't tried hiding the AMPScript, but I bet that would have saved a lot of time today.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .