Activity › Forums › Salesforce® Discussions › How to grant permission to user through apex code? Tagged: Permissions, Salesforce Apex, User Management Salesforce® Discussions How to grant permission to user through apex code? Posted by PRANAV on July 27, 2016 at 3:29 PM Hi All, How to grant permission to user through apex code? Thanks Ajay Prakash replied 8 years, 2 months ago 3 Members · 2 Replies PermissionsSalesforce ApexUser Management 2 Replies Ravi Member July 28, 2016 at 9:51 AM Hi Pranav, You can grant Admin permission to user by enforcing sharing rule (Without sharing)to your Apex class. public without sharing YourClassName{ //Your apex code } [adinserter block='9'] Ajay Prakash Member February 28, 2018 at 5:10 AM Hi Pranav, You can assign permission set to user dynamically using following code in your apex – PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = yourPermissionSetId, AssigneeId = yourAssigneeId); insert psa; Thanks. Log In to reply. Public All Members My Connections Only Me PublicAll MembersMy ConnectionsOnly Me Public All Members My Connections Only Me