5

We are providing a generic global trigger API, enabling some packaged features for any SObject. So customers could possibly invoke it in their Opportunity trigger.

trigger Opportunities on Opportunity (before insert) {
    OUR_NAMESPACE.TriggerApi.delegate();
}

Within our package we are now having some trouble finding out, if a user in the customer org is inserting it in a totally different context, where non of our code should be invoked. Therefore we decided to figure out, if the user has License for our package. The issue here is, that in a lot of sandboxes users do not have specific licenses, since the licenses are so called "Side Licenses" where all the users get an imaginary license. But I couldn't find a way to figure out if a site license exists.

SELECT AllowedLicenses, ExpirationDate, NamespacePrefix, Status, UsedLicenses 
FROM PackageLicense

These are all the fields I can query in the customers org, and they tell me nothing about the type of license. The UserLicense table is empty.

So I hope to find a way to figure out the license type. Since when everybody has access I have to do some more checks and figure out if the feature should be executed.

2

The UserInfo.isCurrentUserLicensed method returns true if the package is licensed to the current user. In Sandboxes, this should always return true, since they are site licenses.

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.