Activity Forums Salesforce® Discussions How to grant permission to user through apex code?

  • 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
    }

  • 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.

Popular Salesforce Blogs

Popular Salesforce Videos