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
sunfishettesunfishette 

SOQL select statement

In my apex class, I am selecting a list of records to be returned to a visualforce page.

 

The question I have is:  how do I limit the records (WHERE clause) to only be returned IF they are assigned to the logged in user?

 

I.E.  "Jack" logs into partner portal, how do I return only his records?

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

You probably mean to add something like the following:

 

WHERE OwnerId = :UserInfo.getUserId()

Each user has a globally unique 15 character identifier, and UserInfo.getUserId() returns this unique identifier.

All Answers

sfdcfoxsfdcfox

You probably mean to add something like the following:

 

WHERE OwnerId = :UserInfo.getUserId()

Each user has a globally unique 15 character identifier, and UserInfo.getUserId() returns this unique identifier.

This was selected as the best answer
sunfishettesunfishette

Yes, exactly.  That worked perfectly.  Bloody brilliant.

 

Thank you.