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
Sumit Kumar Singh 9Sumit Kumar Singh 9 

Get all the user who have access to particular Account record in Salesforce.

I want to get list of user in ApEX cladd who have access to particular Account record in Salesforce.
Ganesh03Ganesh03
Hi Sumit,
You can query AccountShare object to get list of all users or groups that are having access to the account.

Please use below query in yout apex class.
SELECT AccountAccessLevel,AccountId,CaseAccessLevel,ContactAccessLevel,Id,RowCause,UserOrGroupId FROM AccountShare where AccountId ='YourAccountID'

Column UserOrGroupId will contain list of users you're looking for. You can query additional infor as well like access level and all.

For more detail please refer below link.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_accountshare.htm

Hope this will help ! Cheers ! Keep Salesforcing !