8

I have a managed package with a PostInstall script, however I'm having trouble accessing custom objects within it.

Apon installation, I get the following error notification email

System.QueryException: sObject type 'mypackage__Settings__c' is not supported.

The line referenced in the exception is a normal SOQL query against a custom object in the package

Settings__c = [SELECT Field1__c, Field2__c FROM Settings__c LIMIT 1;

Is there any reason why I shouldn't be able to access custom objects in the PostInstall script? It appears to work in other places.

0

1 Answer 1

11

Does your post install script have with sharing in the class definition?

If it does, try removing it or changing to without sharing. There may be an issue with the user that the post install script is running as not being able to access the custom object when sharing rules are enforced.

1
  • 1
    This appears to be the case. My install script was actually a (very big and complex) legacy upgrade script that has existed for a few years, and is now being ported to the new PostInstall infrastructure. As such, there was a lot of code hitting "with sharing" sections of code. Restructuring this so everything ran in a system context fixed the issue. Commented Oct 23, 2012 at 3:16

You must log in to answer this question.

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