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
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Filter entries in an object based on owner-plz help!!!

Hi,

    I have a custom object called Notification__c.Entries are made in this object when a trigger is fired.This object also has a feild Ownerid__c.Now I wanna write a custom page where an owner can see only the records that are owned by him . Can you please tell me how to capture user's info based on their login credentials.I wanr to capture that info and use it in SOQL query like this:

   Select * from Notification__c where (ownerid__c = information provided by login credentials of user )

 

Plz help,it's urgent

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Santosh KumbarSantosh Kumbar

Use below function get current logged in user ID.

 

UserInfo.getUserId() 

 

 

EX:

ID  id = UserInfo.getUserId();
list<account> a = [select id from account where ownerid =: id ];

 

 

regards

San

All Answers

Santosh KumbarSantosh Kumbar

Use below function get current logged in user ID.

 

UserInfo.getUserId() 

 

 

EX:

ID  id = UserInfo.getUserId();
list<account> a = [select id from account where ownerid =: id ];

 

 

regards

San

This was selected as the best answer
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com

Thanks a lot for your help!!!! I have one small query, plz help me with it.

  I wanna show records only on basis of their owners. So i wanna compare Owner field of record with info from login credentials, How can we do this? what is the method for this?

shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com

I mean for every record that you create in any object ,there is an owner field in that object. I wanna match that field with info that I can fetch from user's login credentials.How can I acheive this?

shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com

I have made a mistake in my first post.Ownerid is not a cutom field, its the standard owner feild.

  So i wanaa acheive this:

    owner=userInfo.get (WHICH METHOD TO USE HERE? ID OR NAME?)

Santosh KumbarSantosh Kumbar

I am not understanding ur req...

 

Userinfo methods gives you the output related to current users login.

 

for methods go throgh follwing link:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

 

 

Regards

San