Salesforce: JavaScript Remoting and Managed Packages
I love the crap out of JavaScript Remoting, but came across a small bug when wrapping up the code in a managed package. As many of you know when you create a managed package it prepends your code with a unique name to prevent code conflicting e.g. a page controller called “MyController” becomes “MyPackage.MyController” where “MyPackage” is the prefix you’ve chosen for your managed package. The bug I’ve found is caused by the fact that the prefix isn’t applied to the JavaScript that calls your Apex Remoting methods i.e you might have an Apex method called “myMethod” which is called like so outside of a managed package environment: [code language=”javascript”] MyController.myMethod(parameters, function(result, event) { callback(result); }, {escape: false}); [/code] Once you package up your code however this call will no longer work, and if you look in the debugging console of your browser you’ll find an error something like: “MyController …