Activity Forums Salesforce® Discussions Can we create/delete the permission sets in apex. If yes, how?

  • Surbhi

    Member
    June 10, 2016 at 4:43 AM

    Hi Himanshu,

    Yes, we can create permission set in apex and assign it to user.

    // Creating the permission set
    PermissionSet permSet = new PermissionSet(Label=’Case Permisson Set’,Name=’PermissonSetName’);
    insert permSet;

    //Assigning to the User
    PermissionSetAssignment permAssg = new PermissionSetAssignment(AssigneeId='<Id of User>’,PermissionSetId=permSet.id);
    insert permAssg;

    Also, sObject API is important part of permission sets as it allows you to perform task that you cannot be perform through the permission set UIs.

    Thanks

Log In to reply.