1

I had a plan to create drag and droppable forms in content builder in Marketing Cloud.

I created the forms and I saved them as content areas.

Now when I drop them in a Cloud Page content area all the javascript gets stripped away and the forms are unusable. Both links to scripts and all other javasscript blocks are just gone.

How on earth can I solve this and still let the customer really easy build their web forms by drag and drop?

2
  • 1
    Supplications as to the urgency of your question are not on topic, nor polite. Please take a moment to visit the help center, scroll through the tour, and read How to Ask. A well asked question which is properly tagged and includes all necessary relevant information will typically receive a quick answer.
    – Adrian Larson
    Oct 16, 2017 at 18:46
  • Can you provide a sample of the content as well as more info on the content block you built - e.g. did you use HTML, Freeform, etc. Oct 16, 2017 at 18:49

3 Answers 3

3

I did a bit of research and found that this appears to be a common issue and is likely due to some issue with the HTML editor for the WYSIWYG (I believe it is TinyMCE) and the browser that is clearing this from your content.

As this appears to be a back-end issue, I would alert SFMC global support about the issue.

As a quick and dirty solution, you can create a Data Extension that houses your Javascript inside of it and then use a lookup via AMPScript to fill it on your content block form.

E.g.

Your DE:

Form       JavaScript  
Form 1  |  <script>Your Javascript</script

Then in the content block, place the following lookup():

%%[
SET @jscript = Lookup('yourFormDE', 'Javascript', 'Form', 'Form 1')
]%%

%%=TreatAsContent(@jscript)=%%

This should be a quick workaround to get your need met while waiting for SFMC support to find a more long term solution.

2

Simplest solution is to set the script tag as ampscript variables using concat:

%%[
set @scriptBeg = Concat('<','script','>')
set @scriptEnd = Concat('</','script','>')
]%%

%%=v(@scriptBeg)=%%
your javascript code here
%%=v(@scriptEnd)=%%

I've validated that this works in Code Snippets in content builder.

1
  • 1
    It didn't work yours but this worked ` %%[ set @scriptBeg = Concat('<',"script runat='' type='text/javascript'",'>') set @scriptEnd = Concat('</','script','>') ]%% %%=v(@scriptBeg)=%% console.log ('this is a test '); %%=v(@scriptEnd)=%% ` This issue is documented here help.salesforce.com/…
    – Johhnytska
    Jun 25, 2020 at 20:27
1

Thank you so much for answering Gortonington. Good solution.

However during the night I figured out that I could use the Smart Capture block type and override it with my own code. And Heureka - that worked. It doesn't strip off my scripts and is still possible to save and to drag and drop.

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.