4

I am trying out few Lightning stuff and as a part of that I added namespace to my Developer edition. After doing this I realized that all my preexisting custom object's API name is now prefixed with the namespace. e.g. object name before adding namespae - MyCustomObject__c object name after adding namespace - MyNamespace__MyCustomObject__c

My existing Apex code which is using MyCustomObject__c is working fine. But any new query that I am firing from dev console requires me to add namespace prefix.

my questions is -

what is the impact of adding namespace ? 1. Do we need to revisit all apex code/soql query ? 2. Do we need to recreate enterprise WSDL and correct SOAP API calls ?

Any insight on this would be very helpful.

2
  • 1
    FYI - as of Spring '15 Lightning no longer requires a namespace.
    – Mike Chale
    Commented Mar 8, 2015 at 1:09
  • Correct Mike. but I realized that after adding the namespace and now I can't undo it.
    – apn
    Commented Mar 8, 2015 at 1:31

1 Answer 1

5

Typically you don't have to revisit all of your code. Most things will continue to run after the prefix is added.

But most doesn't mean all. I found these points requiring modifications:

  • Objects accessed via API
  • as a consequence existing integrations and ETL processes
  • Metadata accessed via API including use of Metadata Service.cls for APEX
  • Usage of Ajax Toolkit
  • JavaScript Remoting for Apex Controllers (at least where I used alternate syntax)
  • places where I heavily used Schema methods together with SObject.get() and dynamic SOQL e.g. for this baby here: Howto wildcard SELECT * to query all fields of objects in APEX?
  • this list is likely incomplete. Additions are welcome!

What I try to do is wherever possible to write code that runs with and without namespace and I pay a lot of attention never to hardcode any namespace reference.

With a bit effort you'll get all references dynamically prefixed. Mind that in JS you have to do it at some places with 'prefix.' and in Apex or API typically with 'prefix__'

If you hardcode that you loose portability, meaning you can't just copy or deploy all of your code to a different Org. And this can be serious.

For lightning I asked this question which was answer by Doug and Peter and should cover most aspects.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .