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
mavsmavs 

how to use SOSL from .Net

Can someone please let me know how to use SOSL from .Net?

 

I am using the below query and geeting MALFORMED_QUERY: unexpected token: FIND

 

string txt="Acme"; string query="FIND :"+txt+" IN NAME FIELDS RETURNING Account(Id, Name, Type,BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name WHERE RECORDTYPEID='xxxxxxx')";

 

Please advise...

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf

First of all, your SOSL doesn't look right.  There's no colon operator in SOSL, it should look like

 

FIND {map*} IN ALL FIELDS RETURNING Account (id, name), Contact, Opportunity, Lead

 

Then: you should be using the search() method, not the query() method, to run SOSL.  See some sample code in the docs here.

All Answers

werewolfwerewolf

First of all, your SOSL doesn't look right.  There's no colon operator in SOSL, it should look like

 

FIND {map*} IN ALL FIELDS RETURNING Account (id, name), Contact, Opportunity, Lead

 

Then: you should be using the search() method, not the query() method, to run SOSL.  See some sample code in the docs here.

This was selected as the best answer
mavsmavs
Thanks..

I tried your suggestion, but i keep receiving the error...

MALFORMED_QUERY: unexpected token: FIND

string Acct_query = "FIND {" + searchText + "*} IN ALL FIELDS RETURNING Account (id, name) where RECORDTYPEID='xxxxx' ";
sForce.QueryResult qr = binding.query(Acct_query);
sForce.sObject[] records = qr.records;

Please advise.
SuperfellSuperfell
If you want to use SOSL, you need to call search, not query. (query uses SOQL).