We have a managed package. In order to implement a sandbox / release management process for our application we have made all our code dynamic.

We populate via a custom setting the name of the org's namespace.

How do we implement a dynamic namespace for javascript remoting? http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm


Thanks in advance for your help.

3 Answers 3


The simplest way to have a conditional namespace in a remote action invocation is like this:


I usually set a var on my VF page like this:

 var querySomething = '{!$RemoteAction.Ctl_SomeCtrl.querySomething}';

Then in my JS file:

            function(result,event) {
                //do stuff with result

You don't need to directly reference the namespace at all. You just can't use the JS remoting shorthand.


For those who stumble upon this post looking for any updates here is the SFDC recommended approach of doing this

  • Yep, thats basically what I did in my answer except I assigned the string to a variable. For me, I like having all my remoting calls assigned to variables so they're all in the same place, makes changing them easier.
    – Phil B
    Sep 13, 2017 at 13:55
  • Ditto! Great minds ;) Sep 15, 2017 at 10:30

You must log in to answer this question.