3

I am trying to find contacts by Phone number. I require using SOSL due to it's search excluding non-alphanumeric chars but cannot get the same (or any) results from SOSL as I can from SOQL. I am using the same SoapClient for each....

                var query = @"SELECT Phone FROM Contact WHERE Phone = '999999999'";
                queryRequest objQueryReq = new queryRequest();
                objQueryReq.queryString = query;
                objQueryReq.SessionHeader = header;
                objQueryReq.MruHeader = null;
                objQueryReq.PackageVersionHeader = null;
                queryResponse objQueryResponse = queryClient.query(objQueryReq);
                qr = objQueryResponse.result;

This results in the correct 2 records found. The SOSL equivalent (I must not be doing it correctly!) returns null results...

                searchRequest objSearchReq = new searchRequest();
                objSearchReq.searchString = "FIND {999999999}IN Phone FIELDS RETURNING Contact";
                objSearchReq.SessionHeader = header;
                objSearchReq.PackageVersionHeader = null;
                searchResponse objSearchResponse = queryClient.search(objSearchReq);
                SearchResult sr = objSearchResponse.result;

Any help would be much appreciated!

2
  • 1
    Have you tried doing your SOSL query in the Developer Console to check your syntax ia correct and you get the expected results? Oct 28, 2014 at 12:59
  • Yep just tried it and the query "FIND {999999999} IN Phone FIELDS RETURNING Contact(Name)" is working in dev console. Can you look at the second bit of code and see if anything stands out?
    – Shanyman
    Oct 28, 2014 at 13:52

1 Answer 1

1

It turned out that in .net I was loading the wsdl as a "Service Reference". This was fine for SOQL but doing so for SOSL it flat out did not work, response being no returned records.

If you want to use SOSL load the wsdl as a "Web Reference" - Add Service Reference > Advanced > Add Web Reference

Salesforce should sort this out or at least document how exactly to do it if it is possible, Ive emailed them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .