Syntax Error when trying to escape piped text. | XM Community
Skip to main content

Context: Trying to read in answers to surveys, have a list of 200+ words that we want to compare answers to, flag to proper parties if a certain word is picked up. It works great apart from the issue outlined below.
Issue: I cannot for the life of me figure out how to escape double quotes and backslashes when reading in the piped text. The strangest thing is that I am getting a "Syntax Error: missing ) after argument list" error, which doesn't make much sense. I've been all over Stack Overflow, can't figure it out. Have tried multiple ways of escaping and replacing the double quotes and back slashes, no success. See below for code segment.
var answer1pre = escape("${q://QID4/ChoiceTextEntryValue}");
I've tried doing escape('${q://QID4/ChoiceTextEntryValue}'); replacing the double quotes with single, but then I get hit with the same error if a single quote is entered in the text.
Any help is appreciated!!

Hi,

I would suggest you work with the replace function and a regular expression
for backslash it would look something like
my test string was "Hey there" \\ what's up
the result was: Hey there what's up

Qualtrics.SurveyEngine.addOnload(function()

{

let text2 = Qualtrics.SurveyEngine.getEmbeddedData("text2")



text2 = text2.replace(//"]+/g, '')



text2 = text2.replace(/\\\\/g, '');



console.log(text2)
});
best regards

Rudi



Leave a Reply