Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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?

share|improve this question
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
    
thanks for the encouraging feedback @jkraybill –  user320 Feb 28 '13 at 0:37

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
1  
Nice! I'm confident the packaging Org Id is not gonna change ;-) happy to hard code! –  user320 Feb 27 '13 at 15:13
    
Thanks, have added that to the answer –  Stephen Willcock Feb 27 '13 at 15:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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