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
Dhivya KDhivya K 

SOSL search by id

Hi,

I wanted to retreive contact object that is mapped to a specific account. Is this possible with SOSL? I am getting null contacts for the given accountid. If this is not possible, kindly suggest me an alternate that could fetch all contacts mapped to a account,website id,etc.

This is my query:

            String soslQuery = "FIND {" + accountid + "} IN ALL FIELDS " +
                "RETURNING " +
                "Contact(Id, Phone, Email, FirstName, LastName, AccountId,CEB_Id__c LIMIT 1), " +
            "Account(Id, Phone, Name)";

Thanks
tamizharasan pushparajtamizharasan pushparaj
You can try this through SOQL

Select id, phone, email, firstname. lastname, accountid , CEB_ID__c, Account.phone, Account.name from Contact
DeveloperSudDeveloperSud
Hi Dhivya,

You can search text, email, and phone fields for multiple objects, including custom objects in SOSL.We cant search using the id field it seems.To solve your issue you can create a text field with a name like "theAccountId" and populate the filed with value of the corresponding account ID.Then you will be able to use that in SOSL.Hope this will help you to solve your problem.