Control script for Print section and Email section

I have a template with a few print sections and a control script dictating which print section to produce based on a couple fields in the data file. This works fine. I now need to add a couple email sections in the template. I added to the control script and it isn’t working. One example of what I added is below. Attached is my script. I am getting an error - One says Parser$ParserException and the other says invalid assignment left hand side.

I have tried two separate scripts. I even copied an existing script for the emails that works in another template and made the necessary changes and I still get the same errors.

Print_Email_script.txt (4.6 KB)

Thank you

Can you share an anonymized version of your Template and Datamapper?

merge.template.contexts.HTML_EMAIL.sections.Non-Pershing.enabled = true;

That should be:

merge.template.contexts.HTML_EMAIL.sections["Non-Pershing"].enabled = true;

The brackets are necessary because the dash in Non-Pershing is not a valid character for a JavaScript identifier.

Note that if you type this:

 merge.template.contexts.HTML_EMAIL.sections

… and then add a dot (.), you’ll see a list of section names. After selecting Non-Pershing the brackets are added automatically.

2 Likes

That worked - thank you very much!!