function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eric Blaxton 11Eric Blaxton 11 

How to pass single quote in Odata 4.0 query

Hi and thanks in advance.

I wrote an OData query and it worked until I added a Not Contains filter
String exclude = 'Variance';
and%20not%20contains(shortDescription,'+ exclude +')
Resulting query is:
not%20contains(shortDescription,Variance)
My question is how do I get single quotes around the variable.

Thank you,
Eric

 
Best Answer chosen by Eric Blaxton 11
Eric Blaxton 11Eric Blaxton 11
Update to help out anyone with same question.

I created a variable which contains the single quotes like this:
String exclude1 = '\'Variance\'';

Then in the Odata 4.0 query I added the variable like this:
 
%20not%20contains(shortDescription,'+ exclude1 +')

 

All Answers

VinayVinay (Salesforce Developers) 
Hi Eric,

Any SOQL query for the external object should be in below format.
 
http://services.example.org/my.svc/Suppliers?$select=SupplierID&​$count=true&$top=26

Reference:
https://help.salesforce.com/articleView?id=odata_query_string_options.htm&type=5#system_query_option_count

Thanks,
Eric Blaxton 11Eric Blaxton 11
Update to help out anyone with same question.

I created a variable which contains the single quotes like this:
String exclude1 = '\'Variance\'';

Then in the Odata 4.0 query I added the variable like this:
 
%20not%20contains(shortDescription,'+ exclude1 +')

 
This was selected as the best answer