SOQL IN String Literals
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?
@Damone
do it all in SQL
ie
IF EXIST(Select id from table_x where id=@id)
BEGIN
UPDATE table_x set col1=@col1 where id=@id
END
ELSE
BEGIN
INSERT INTO into table_x (id,col1) values(@id,@col1)
END