You need to sign in to do that
Don't have an account?
NipuW
Please clarify the following
In SOQL when you do a select on Account and contact it returns a single list with accounts and contacts both. But with SOSL it rerutns nested list. Why?
List<Account> acctsWithContacts = [SELECT Name, (SELECT FirstName,LastName FROM Contacts)
FROM Account WHERE Name = 'SFDC Computing'];
List<List<SObject>> searchList = [FIND 'SFDC' IN ALL FIELDS
RETURNING Account(Name), Contact(FirstName,LastName)];
List<Account> acctsWithContacts = [SELECT Name, (SELECT FirstName,LastName FROM Contacts)
FROM Account WHERE Name = 'SFDC Computing'];
List<List<SObject>> searchList = [FIND 'SFDC' IN ALL FIELDS
RETURNING Account(Name), Contact(FirstName,LastName)];
Because in SOQL It will only return those contact which are child of Accounts, So they came in Single list.
While in SOSL there can be totally different Account, Contact Which may be not related with each other. So thats why it return them as List of list.
If this answer helps you, please mark it as accepted.
Regards,
Tushar Sharma
https://newstechnologystuff.com/