function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VirajViraj 

Want get the namespace of the Salesforce org

Hi,

 

Is there a way to get the namespace prefix of a Salesforce organization using Apex code ?

 

I have developed an AppExchange application. This application need to know the namespace of the Salesforce organization to create a record.

 

Thanks

Viraj

rscottrscott

What record are you creating? As far I as know, namespaces are only used for custom objects and fields in managed packages.

VirajViraj

 

I am creating a Visualforce page and some static resources. To use the static resources in the Visualforce page I must know the namespace of the org. Therefore I must know namespace of the org before creating the Visualforce page.

 

Viraj

rscottrscott

Sorry, I'm confused now. Originally you needed to create a record. So, you need to access static resources in a company's org from a VF page in your packaged AppExchange app? I thought namespaces only came into play when accessing components in a managed package.

Pradeep_NavatarPradeep_Navatar

The namespace prefix is added to Apex classes and triggers, Visualforce components and pages, brand templates, folders, s-controls, static resources, web links, and custom report types if they are included in a managed package. However, if your profile does not have customize application permissions, the namespace prefix field is not displayed for brand templates, folders, and custom report types.

VirajViraj

OK.

I have another question.

Does Salesforce allow to put namespace to production organizations ?

 

Viraj

Pradeep_NavatarPradeep_Navatar

Please create a new thread for the new question.

Rohit RadhakrishnanRohit Radhakrishnan
Try this: 
string namespace  = [SELECT NamespacePrefix FROM Organization].NamespacePrefix;