Authored by Zishan Razzaq

Friday, February 27, 2009

Dynamically generate the logged in user's id Syntax in Salesforce.com

Scenario:
Place on the home page sales history information by user for only that user.

Tools needed:
Apex Class/Trigger/Controller
VisualForce

I will go into the code part later. But to get the id of the user dynamically and have your VF page component added onto your Home Page Layout working. In your SOQL query under your Apex Controller/Class you must use the following:

UserInfo.getUserId();

So in SOQL, in Apex code you can do:
Select Id, Owner.Id, Name, Site from Account where Owner.Id=:UserInfo.getUserId();

I hope this helps....
Thanks
Check out my Other Blogs:
VisualForce Made Easy
Data Migration Made Easy

No comments:

Post a Comment