Javascript Remoting breaks on complex relationship data

We use Javascript Remoting to retrieve some complex data from the controller. The SOQL query looks like the following:

    ( SELECT Id, Sales_Rep__r.Name, Customer__r.Name,
    Customer__r.FirstName, Customer__r.LastName,
    Customer__r.ShippingStreet, Customer__r.ShippingCity,
    Customer__r.ShippingState, Customer__r.ShippingPostalCode,
    Customer__r.PersonHomePhone, Customer__r.PersonMobilePhone,
    FROM Bookings__r  
    WHERE (Sales_Rep__r.Territory__c = :region OR Region__c = :region ) AND (
    Status__c = 'Pending' OR Status__c = 'Confirmed' ) )

FROM Timeslot__c WHERE Date__c >= :fromDate AND Date__c <= :toDate

It worked perfectly until last weekend (25 May 2013). Since then, the Sales_Rep__r property of Booking__c child records in the returned Timeslot__c is sometimes undefined even though the corresponding Sales_Rep__c contains the correct id.

We were able to recreate it with a barebone test page with no javascript library at all, just the JS remoting call to the backend. In addition, we were able to see the correct data in the Apex debug log just before it is sent out. So the problem definitely lies with the JS remoting library.

This issue happens on the latest versions of Firefox, Chrome, IE. Only Firefox 20 and Safari continue to work fine.

I’m wondering if anyone else experiences the same issue or if anyone can give any pointer to help resolve it?

Update: The SOQL result is converted into a map and passed straight to the front-end. The code for the test page on the front-end goes like this:

window.onload = function(){
  BookingCtrl.getTimeslots( '2013-05-28', '2013-05-28', 'Brisbane North',
    function( result, event ) {  
      _.each(_.values(result), function(slot){
        if (slot.Bookings__r)
          _.each(slot.Bookings__r, function(booking){
            if(booking.Sales_Rep__r == undefined)

The Sales Rep record that goes missing is no different from other user records (no special characters, etc.) That same Sales Rep shows up in some other bookings. So I would rule out the possibility that it is the cause of the problem.


When you use ajax toolkit , it is just a rest callout and you just send query as a data. So there should no impact of browser as all browser support Ajaxrequest.

There may be following problems :

1) check the all related fields and objects security settings and accessibility setting.
2) You will be able to see query result in apex class controller if you write class without sharing.

Source : Link , Question Author : hoangmphung , Answer Author : ashishcloud

Leave a Comment