I'm considering this workaround to determine whether a class is running in unmanaged or managed context when calling System.requestVersion().

The documentation of UserInfo.isCurrentUserLicensed defines the method as follows:

Returns true if the context user has a license to the managed package denoted by the namespace. Otherwise, returns false.

In this case, what does 'License' refer to if I have a site-based package? There are no licenses to assign to users, they'll typically all have access. So if a user of the package has this installed, can the method always be expected to return true for this org?


Yes, Site-based licenses report "true" for all user contexts. You can test this in a Sandbox to prove this to yourself (all apps installed in Sandboxes have perpetual Site-based licensing).

| improve this answer | |
  • Awesome, thanks! I'll definitely test it out, just wanted to see if there were any special exceptions where the behavior would be different. – zeneto Jan 3 '18 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.