You need to sign in to do that
Don't have an account?

SOSL Query for Contacts by Account Name
Hey all. I am trying to refine a search functionality I have developed. I want the search string the user enters to search ALL FIELDS to return as many relevant results as possible. However, I am expecting certain data to show that aren't. For example, I have an account with the Account Name of "Worldwide Acme Holdings". The user is entering the search string "acme". There are lots of Contacts associated with that account. However, the search results do not yield any of those contacts. Here is my query:
Am I doing something wrong here? Technically the field with the Account Name label in SF is an Id/Lookup field. Is that why? Any viable workarounds?
Thanks!
allAccsCons = [FIND :searchString IN FIELDS RETURNING Contact(Name,Id,AccountId,Email,Phone,Account.Name),Account(Id,Name,Type,BillingCity,BillingState,Industry)];It doesn't seem that the SOSL query is looking at the "Account.Name" value for the Contact sObject. The account results themselves do contain the Account mentioned above. But, I am wanting a contact list as well of all contacts who are part of that account.
Am I doing something wrong here? Technically the field with the Account Name label in SF is an Id/Lookup field. Is that why? Any viable workarounds?
Thanks!
Note that RETURNING clause is used to specify the the fields that will be returned from the records after the search operation. those fileds are not used for search.
In your controller you have to issue a SOQL to get the related contact or account record using the list of id returned by the SOSL.
For valid search group settings look at the link below
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_sosl_in.htm
All Answers
Note that RETURNING clause is used to specify the the fields that will be returned from the records after the search operation. those fileds are not used for search.
In your controller you have to issue a SOQL to get the related contact or account record using the list of id returned by the SOSL.
For valid search group settings look at the link below
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_sosl_in.htm