I have doubts with name-space appending with few scenarios scenarios are:

  • Dynamic SOQL
  • Schema.getGlobalDescribe() : using SOBJECT
  • Storing field in custom setting Field Values.

Do I need to merge package namespace in all these scenarios? Or after package installation, will Salesforce do it itself?


With precious few exceptions, which you'll likely discover when/if you run in to them, the system patches namespaces automatically.

Dynamic SOQL

You can't query "non-namespaced" fields or objects that have the same name as namespaced versions of the same. So, given a query like this:

 String query = 'SELECT Id, Name__c FROM Custom_Obj__c';

It will always refer to your Custom_Obj__c, even if there's another in another namespace, or if the client has the same object name. It's not actually possible query the client object because of this shadow effect.

Schema.getGlobalDescribe() : using SOBJECT

You don't need to prefix it, because again, you'll be locked in by the shadow effect.

Storing field in custom setting Field Values.

It depends on how you're using it, but again, generally speaking, the system will prefer to use your namespaced objects to subscriber objects and fields.

Summary: In general, don't worry about it. Unless you're trying to access subscriber fields, or you meet very specific criteria that I can't think of off the top of my head, things will naturally "just work." In fact, you should assume that they will until/unless you do some testing and find the contrary to be true. They're usually related to bugs or gaps in the system, and will likely vary from release to release.

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.