confusing field doesn’t exist error from javascript remoting

I’m getting the following error from javascript remoting while logged in as a auth. sites user in the portal:

No such column 'mynamespace__Contact__c' on sobject of type mynamespace__Contact_s_Form__c

There are a few weird things about this:

  1. that is the exact name of the field and object (I changed the namespace above)
  2. the user has permission to that field and both VF pages.
  3. the apex in the constructor is getting a record for that object and field, and its actually passing it to the remote method throwing the error
  4. another page is calling the exact same remote method and sending the exact same record and there is no error
  5. NOTE: there aren’t any actual contact fields being rendered on the page its just part of the search in the JS remoting method so its not an issue of them not having permission to the contact object, plus once again, it works on the other VF page.

Things I’ve tried:

  1. Ripping this page and controller out of the package and recreating it directly in the customer org including all namespace updates, and…it works! Why!?

Identify the differences between the page that works and the one that doesn’t:

  1. The one that works inherits the controller of the one that doesn’t, so they’re literally calling the exact same remoting method.
  2. In the JS console I can see I’m passing the exact same record to the remoting method.
  3. The one that works has sidebar="true" showHeader="true" standardStylesheets="true". The other does not.
  4. There are a few other minor differences between the two pages but none that look to be even somewhat relevant.

What I feel like it really boils down to is I’m sending the same record to the same method on 2 different pages. One it throws an error, the other it does not.


I was able to figure it out FINALLY!

I was inspecting the actual XHR request in Chrome dev tools. I noticed under ctx under the payload there was a ver property. I realized this corresponded to the API version of the controller and was 32 in the page that worked and 28 on the one that didn’t.

So the page that worked extended the controller of the page that didn’t work. The API version of the child controller was newer than the API version of the parent controller. So, even though the working one was calling the method from the parent controller the XHR request was still using the newer API version of the child controller. While the page that wasn’t working (parent controller only) was still using the old API version.

I guess the lesson is update the API versions of controllers. Though the error message I got back was pretty misleading.

Source : Link , Question Author : Phil B , Answer Author : Phil B

Leave a Comment