I have post install script that is suppose to create records belonging to a certain custom object and all other custom obj records related to it.
In my onInstall method I am querying if the current org contains data belong to that custom obj and if it does not then it creates the above mentioned data.
Something like this:
global void onInstall(InstallContext context) {
List<CustomObj__c> objList = [select Id from CustomObj__c];
if(objList != null && !Test.isRunningTest()) {
createRecordsForCustomObj();
}
}
private void createRecordsForCustomObj() {
//this method creates data for custom obj
CustomObj__c obj = new CustomObj__c();
obj.Field1__c = 'value';
obj.Field2__c = 'value';
insert obj;
}
And so on it would create other related records. My problem is, the post install script wont run. On installation it does not give any errors (package failed or anything else). The package installs smoothly but when I go and check if the data was created for that CustomObj__c, it is not.
Is there something wrong in my code or am I suppose to do some setting on the new org before installing a package?
Oh FYI: I am creating a Beta package, dont know if that factor comes into play.
Thanks.