I have requirement like in managed package, we have a custom field on Contact Object. We need to grant the edit access to this custom field for all the users who have Create access on the Contact object.
So we have created a Permission set for the same, but identifying correct user & assigning permission set to them manually is time consuming & we want after package installation permissions should be set automatically.
So we have written apex code in Post Install Class of the managed package to assign the permission set to the users using PermissionSetAssignment object.
PermissionSetAssignment assignmt = new PermissionSetAssignment();
assignmt.PermissionSetId = permission set id
assignmt.AssigneeId = user id;
But when have created a new beta version of managed package & trying to install it on one developer org then showing error as below:
Problem: 1. Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.