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
calvin_nrcalvin_nr 

Is it a good idea to use SOQL to limit records by Account id of logged in user?

Our org currently has "public read" permissions on our org wide defaults. We cannot make this private.

I am creating a customer portal with custom visual force pages...where I display data using SOQL queries.

 

Is it a good idea to add a clause on the SOQL query to return only those records where the account id matches the logged in user's acount id?

 

And if yes..how can I get the currently logged in user's acount id?

 

Thanks.

SFRajSFRaj

Hi,

 

Create formula field in User Object. Formula is Contact.Account.Id. Then query that field.

calvin_nrcalvin_nr

Hi SfRaj..Thanks for replying. I did solve the problem of getting the account id...

 

But I wanted to see if my approach is correct...i.e the original question of whether using SOQl to limit record accessby account id is a good idea.