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
eelliseellis 

Javascript remoting in managed package

I'm working on a visualforce page that requires some javascript remoting.  I've run into a funny issue that I'm hoping someone will have run into before and help me out.  This page has been developed and working for a long time but has just recently started to give us problems.  It now throws a javascript error: line 122 on VFRemote.js: "Uncaught TypeError: Cannot read property ‘RemoteClassController’ of undefined".  Here is the current code: 

In javascript:
function save(){
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.RemoteClassController.remoteMethod}',param1,param2,param3,handleUpdatesCheck);
} function handleUpdatesCheck(result, event) { ... }

Controller:
global with sharing class RemoteClassController {
@RemoteAction
global static List<String> remoteMethod(String param1, String param2, String param3){
...
}
}

 

This javascript remoting call works (nothing else changes):

RemoteClassController.remoteMethod(param1,param2,param3,handleUpdatesCheck);

 

I'd really like to get this figured out and use the original code.  We are using managed packages and the original code works nicely with being packaged.  We're using API version 26 right now.  Does anyone know why this error is being thrown??

 

Thanks!

MollymulesMollymules
Did you find a solution to this issue? I've come across the same thing recently.
eelliseellis

I don't believe we ever resolved this issue.  I think I ended up changing the remoting and using the second option.

MollymulesMollymules
Thanks for your reply. Actually ended up solving it. It wasn't anything to do with the error really.
ArtieBrosiusArtieBrosius

I'm dying to know what your solution was, becuase I'm having the same problem right now!

ArtieBrosiusArtieBrosius

Alright, I figured out the issue I was having.  I was attempting to use the {!$RemoteAction...} syntax with a .js file loaded from a StaticResource.  The merge field is not resolved correctly, which makes sense now that I think about it, since it gets loaded directly into the page and never gets processed by the VF rendering engine.

 

Bottom line: put all your RemoteAction js calls into the VF page itself if you want to use the merge syntax to resolve namespace issues.