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
saurabhEventsaurabhEvent 

SOSL Find All

Hi All,

 

I am looking to construct a SOSL query where I need to do a find all of Accounts and Contacts owned by a logged in User.

 

FInd {__} in ALL Fields returning Account, Contact LIMIT 100

 

What should I put in the text field(__) for my SOSL so that I return all records.

 

Thanks in Advance!

SuperfellSuperfell

You can't get that result set from a sosl search, you'll want to do a soql query, e.g.

 

select id,name from account where ownerId='the user's id'

 

how exactly you get hold of the usersId will depend on how you're running the query.

Ankit AroraAnkit Arora

My understanding is same as of Simon and here is the query which will return you all Accounts and Contacts owned by the presently logged in user.

 

List<Account> accList = [select id,name from Account where OwnerId =: UserInfo.getUserId()] ;
List<Contact> conList = [select id from Contact where OwnerId =: UserInfo.getUserId()] ;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

saurabhEventsaurabhEvent

Thank you all..

 

I want to save 2 Queries so wanted to try with the SOSL route.