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.