In working through what I thought would be a simple flow, came across a need to strip HTML from some text. I settled on using a "Run JavaScript" action to pass the value through in order to return a plaintext string of text. Unfortunately, I'm finding that as soon as I try to incorporate any variable from within the PAD environment into the JavaScript, the whole action (Run JavaScript) silently fails.
To test this, I set a variable of EventDescription to the value of:
<p>Caffè Lena and the Saratoga Springs Public Library join together to celebrate Banned Books Week. On October 5, enjoy music from Reese Fulmer and Dan Berggren, as well as local authors who will share readings from titles that have been banned or challenged in the past 60 years.</p>
<p>Both organizations recognize the contributions of authors and illustrators amid the current national uptick in efforts to ban controversial books from libraries, suppressing conversations and the ability to think for ourselves.</p>
<p>This program is presented by</p>
My "Run JavaScript" action contains the JavaScript code below:
var myVar = "%EventDescription%";
WScript.Echo(myVar);
After running just these two actions, the return value of the "Run JavaScript" action, set to default of JavascriptOutput, is empty. If I change "myVar" to a value that is not rendered from a PAD environment variable, but just insert text inside the quotes, JavascriptOutput has a value.
There aren't many examples online of how to properly take advantage of this action, and how to properly inject external variables into "Scripting" actions. I've also tried assigning the myVar variable to %EventDescription% without surrounding quotes, without success.
Any thoughts as to what I need to do to fix this? I have to imagine I'm doing something quite silly.
When %EventDescription% is wrapped in quotes, I get a ScriptError of "Unterminated string constant". When not wrapped in quotes, I get a ScriptError of "Syntax error".