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; 
  insert assignmt;

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.


1 Answer 1


Please try the class with "Without Sharing".

As per one of the thread - InstallHandler runs under ghost user.

See this thread for detailed answer - InstallHandler runs under a special ghost user. What rights does it have?

  • Thanks Ysr, but if we used 'without sharing' then this error may not occur but as it's a managed package so in security review they will not allow 'without sharing' for class. Commented Jul 7, 2021 at 4:42
  • not necessary. Even if required, we can mention in the false positive.
    – Ysr Shk
    Commented Jul 7, 2021 at 4:48
  • okays will check. Thanks Yasar. Commented Jul 7, 2021 at 4:52
  • @PratapJadhavar - Did this ever work for you?
    – Prabhan
    Commented Mar 17, 2022 at 12:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .