1

I'm trying to use AMPscript in Content Builder and am getting a lot of HTML being added to the code. For example :

%%[
var @a,@b,@c
set @a = 1
]%%

Generates an error because a <br /> is added after the c in the var declaration and it complains of a syntax error - missing a comma

This is only visible in the HTML editor, the garbage HTML isn't visible in content builder.

Is this normal? I'm finding this tool frustratingly unusable. Is it a local setup issue?

| improve this question | | | | |
  • 3
    %%[ var @a,@b,@c set @a = 1 %%]this is wrong ampscript. the syntax to close an ampscript block is ]%% not %%] – Johannes Schapdick Feb 18 '19 at 12:58
  • Apologies, it was a typo in my question here, not in the code. – harry Feb 18 '19 at 14:27
1

You need to edit the ampscript in code view, and not in wysiwyg mode. Otherwise, your line breaks, etc. will be translated to HTML.

| improve this answer | | | | |
  • If I set it to code view, the left side panel displays a lock. If I click the right hand screen it flips back to layout. – harry Feb 18 '19 at 13:46
  • It sounds like you want to edit ampscript in the template, that is locked? – Lukas Lunow Feb 18 '19 at 16:10
  • Thanks Lukas. I actually come to this from a programing background, but 0 salesforce knowledge. My daughter presented me a non-working email and asked for help. The entire AMPscript was on one line, so naturally I started reformatting the AMPscript to make the logic readable. That's when all the HTML weirdness started getting added. They've received no training on using this, so it seems that all their code is in a text block, and they've done it on one line to avoid the addition of HTML. What's the normal why of adding an AMPscript block without adding HTML? I expected %%[ ]%% would be enough – harry Feb 18 '19 at 20:48
0

Content Builder tends to leave my basic ampscript commands alone, but whenever I try to do anything more complex - like putting it in the middle of a sentence in a text block, or using loops to generate rows in a table, whenever I save the block, SFMC adds a bunch of junk HTML code in to try and 'fix' it.

Unfortunately it's a known issue and the only response I had from Support was to use the Basic HTML blocks instead of the Free Form Block editor for these. It works fine when I does that and does not try to mess with the code.

| improve this answer | | | | |
  • 1
    When you insert HTML to normal text-blocks ampscript is usually going to be bad because you should never consider placing ampscript in normal text blocks. all special characters get changed. Stuff like & " ' ... here are some examples: w3.org/wiki/Common_HTML_entities_used_for_typography. I would encourage you to never use ampscript in those textblocks. – Johannes Schapdick Feb 18 '19 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.