cancel
Showing results for 
Search instead for 
Did you mean: 

SOQL IN String Literals

tarena
New Contributor III

I’m trying to pass a String into a Salesforce SOQL query formula. The String is created in an Aggregate snap, which concatenates Ids from records that were queried from another system, and a Mapper. The mapper restructures the string to conform to SOQL requirements by replacing the pipes with commas, wrapping each item in single quotes, and adding parentheses. Below is the expression:

“('”+$IdString.replaceAll(“|”,“‘,’”)+“')”

The String Literal looks perfect, but when the String is sent to Salesforce all the single quotes are escaped.

(‘a022I00001Jm7uRQAR’,‘a022I00001JmCJpQAN’,‘a022I00001JmGqWQAV’,‘a022I00001KIIGGQA5’,‘a022I00001KIzjeQAD’,‘a022I00001KJQWyQAP’,‘a022I00001KOnhYQAT’,‘a022I00001KQzAcQAL’,‘a022I00001KRTMeQAP’,‘a022I00001KRu4kQAD’)

gives the error:

“message”:“\nAND Id IN (\‘a022I00001Jm7uRQAR\’,\‘a022I00001JmCJpQAN\’\n ^\nERROR at Row:4:Column:11\nline 4:11 no viable alternative at character ‘\’”

How do I pass the formatted string to Salesforce without the quotes being escaped?

1 ACCEPTED SOLUTION

tarena
New Contributor III

Answering my own question, there is a checkbox in the SOQL snap to escape single quotes from parameters. If this is unchecked, the single quotes will be passed to Salesforce as-is and are evaluated correctly.

View solution in original post

1 REPLY 1

tarena
New Contributor III

Answering my own question, there is a checkbox in the SOQL snap to escape single quotes from parameters. If this is unchecked, the single quotes will be passed to Salesforce as-is and are evaluated correctly.