3

I can think of at least three different 'environments' for my code:

  1. installed, in a customer org,

  2. unmanaged, in a cloned dev org,

  3. managed, in the packaging org,

The first case can be covered by UserInfo.isCurrentUserLicensed('ns')

The second case can be covered by SObjectType.KnownObject__c.Name.startsWith('ns__')

But I'm actually struggling to differentiate the second and third case! Any ideas?

  • 1
    Wouldn't post this as a comment if PMs were allowed, but who are you? Your questions and answers are great and you are pretty much the only anonymous user I can say that about here. – jkraybill Feb 27 '13 at 16:36
6

Once you have a managed package you will know the Org id of your packaging org (and that's never going to change). In your code you could check the Org Id using UserInfo.getOrganizationId() against the packaging org id (hard-coded)

(1) the namespace will be present, but the org id will not be the same as the packaging org id
(2) the namespace will be absent
(3) the namespace will be present, and the org id will be the same as the packaging org id

|improve this answer|||||
  • 1
    Nice! I'm confident the packaging Org Id is not gonna change ;-) happy to hard code! – bigassforce Feb 27 '13 at 15:13

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.