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
Pavushetti Abhilash 3Pavushetti Abhilash 3 

Grant permission to user using apex code

Hi eveyone. I am beginner. 
I need to give view all permission to object(eg:accounts) to a specific user(another profile, not an Admin) so that object data can able to view by that user. How can I achieve this through apex code. Please let me know.
Thanks
AnkaiahAnkaiah (Salesforce Developers) 
Hi Abhilash,

You can achieve this by using permission set. Create permission set with account object access as View All and assign it to the repective user.

Please refer the below for your reference.
https://help.salesforce.com/s/articleView?id=sf.perm_sets_create.htm&type=5

If this helps, please mark it as best answer.

Regards,
Ankaiah bandi