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
AnuAnu 

Salesforce API search fails when the search string has "-"

Hi,

I am using sforce api 'Search' function to search leads and contacts based on their email address.

SearchResult sr = sfdc.search("find {" + searchString + "} in ALL fields returning lead(id),contact(id,accountid)");

If searchstring has "-" ex: anu@anu-company.com  the search fails with malformed query error.

Is there a solution around this?

I am using C#.

Thanks in Advance,

Anu

SuperfellSuperfell
As indicated in the SOSL docs, - is reserved, you need to escape it with the \

see http://www.sforce.com/us/docs/sforce50/sforce_API_calls_SOSL.html#wp1455933