I have a managed package that can be installed in multiple organization types. Attempting to use the following query causes install failure when used in my postinstall script.
[SELECT OrganizationType from Organization LIMIT 1]
Is it possible to get the organization type in a postinstall script so that I can enable/disable necessary features?
Update: What I really need to know is if my package has been installed in a Professional edition org. I can do without actually knowing the type.
Attribution to: csnullptr
Possible Suggestion/Solution #1
Don't forget that the postinstall script runs as a user with some pretty funky permissions, so test carefully (meaning do installations of a beta package) because standard unit testing won't reveal installation errors.
Also, Organization is only accessible to users with View All Data permission (or Modify All Data), so you may need to work around that or ensure that only System Administrators install your package.
Having said that, Organization is available to the postInstall user in all orgs.
Attribution to: DavidSchach
Possible Suggestion/Solution #2
[SELECT OrganizationType from Organization LIMIT 1]
does work in a professional edition org.
It turns out that there was reference to a field in my code that isn't supported in a Professional Edition org. That's why I was getting an error when attempting to install in a Professional Edition org.
Attribution to: csnullptr
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30998