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 have a dev org, in which I have got a namespace prefix. In apex, I want to get this namespace prefix as string. Is there any straight way or I have to describe some object?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Query for it, using a class that you know will be there:

ApexClass myClass = [
    select NamespacePrefix
    from ApexClass
    where Name = 'SomeClassNameHere'
];
share|improve this answer
add comment

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.