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
miha198206miha198206 

Error when escape '&' symbol in SOSL FIND statement

I have a code to find 'Why & not' keyword:

 

 

String query = 'FIND \'Why \\& not\' IN ALL FIELDS RETURNING Contact LIMIT 200';

List<sObject> sObj = Search.query(query)[0];

 

I escaped '&' symbol but when I run this code I get the error: 

 

 

line 1:10 mismatched character '\' expecting '''

 

How can I solve it?

 

Thanks.

 

 

Ankit AroraAnkit Arora

Let me know if this gives you any error.

 

 

String query = 'FIND \'Why & not\' IN ALL FIELDS RETURNING Contact LIMIT 200' ;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page