I am creating a package. I have did a mistake and that mistake is Object that i have created starts with 00000. But my logically it should have been started with 00001. But now I am not able to change the starting point of the record in package.

So my solution was to run an post install script insert the 00000 th record and then hard delete the same.

I tried it alos anhere is my code

global with sharing class PostInstallHandler implements InstallHandler
    global void onInstall(InstallContext context) 
        if(context.previousVersion() == null) { 
                Settings__c scSettings= new Settings__c();
                insert scSettings;
                delete scSettings;
                //Delete records from recycle bin.
                List<Id> toDelete = new List<Id>{scSettings.id};
                }catch(exception e){

But when i try to install package following error is thrown 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
    From recyclt bean you can not delete the record during postinstallscript. as in that case package name is known as owner of that record . only logged-in user can delete.
    – Ankuli
    Commented May 15, 2015 at 11:54
  • Thanks for the reply Ankuli, Is their any another approch to solve this problem. Commented May 15, 2015 at 13:52
  • I have removed code which deletes record from recycle bean, but getting the same error. Is it that we are not able to delete records in post install script? Commented May 28, 2015 at 12:00

1 Answer 1


Try to remove the with sharing of your class

global class PostInstallHandler implements InstallHandler{ ... }
  • I haven't understood how this can help me, sharing rules for the current user are not enforced if we do not use with sharing. Can you please explain.... Commented May 28, 2015 at 10:58
  • 1
    This post install apex script runs under a "ghost user" and removing the with sharing you would allow the user View and Modify all data and also. @bigassforce did an amazing research on this topic: salesforce.stackexchange.com/questions/32607/… Commented May 30, 2015 at 16:34

You must log in to answer this question.

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