Salesforce SOQL integration "SyntaxErrorUnexpected token" fix

Hi everyone,

I am new to
Yesterday when I tried to create a workflow involving Salesforce SOQL search, I notice that if you put an equal sign “=” in the SOQL search, it will create JSON Syntax error:

SyntaxErrorUnexpected token : in JSON at position 71.

What happened is that in the Salesforce webhook URL query has equal sign “=” reserved. And the javascript function “encodeURI()” creates an error in the source code:

Line 23: url: ${this.salesforce_rest_api.$auth.instance_url}/services/data/v20.0/query/?q=${encodeURI(this.soql_search_string)},

So what you need to do, is to copy and paste the entire source from the page, and set it as “custom code” instead, with Line 23 encoding the SOQL string with “encodeURIComponent()” replacing “encodeURI()” as the following:

Line 23: “url”: ${this.salesforce_rest_api.$auth.instance_url}/services/data/v53.0/query/?q=${encodeURIComponent(this.soql_search_string)},

And it will fix the issue, allowing you to use SOQL query with equal sign “=” like:
SELECT Id, Name FROM Contact WHERE Email = ‘{{steps.trigger.event.body.Email}}’

It took me a few hours to fix it, hope this post will save your time if you have a similar issue.

1 Like

Hi @andyyip thanks for the tip!

Sorry about this bug, I’ve filed it on our public Github tracker so a component dev to can look into it.

1 Like