4

Does anyone know how to or if it is possible to pull data from the related list of an object using Remote Objects? I can query the object's related list without error however it is undefined and I cannot seem to find references on this in the documentation.

  • 1
    Can you please share sample code ? – Jitendra Zaa Aug 20 '15 at 16:51
  • It is more of a general question as to whether or not Remote Object Queries allow for querying of related lists. – binaryLady Aug 20 '15 at 18:26
3

Bit late to the party, but as far as I can tell (and from experimenting) you can only query fields on the object itself. This means to get related information you then have to make subsequent calls to those objects filtering by the lookup Id.

This is a snippet of code I've been using (note I'm using UnderscoreJS to help out a little).

// Client id is my JS name for the ContactId field
var clientIds = _.uniq(events.map(function(e) { return e._Client; }));
clientIds = _.reject(clientIds, function(c) { return !c; });

if(clientIds.length === 0)
{
    success(events);
    return;
}

// this method perforces a remote object query on contact
self.loadClientsById(clientIds, function(clients)
{
    var mapped = events.map(function(e)
    {
        for(var i = 0; i < clients.length; i++)
            if(clients[i].Id === e._Client)
            {
                e._Client = clients[i];
                break;
            }

        return e;
    });

    // now mapped is an array of events, where each has a contact object
    // contained within it under the _Client property;
    doSomeCallback(mapped);
});
  • 1
    Hi Lacey, that is what I have found also... it would be a nice feature to be able to access related objects without another call – binaryLady Sep 3 '15 at 16:16
  • Absolutely. Also, I have just discovered that remote objects can be very slow when searching across large data sets. I'm not sure why but it was timing out at around 30 seconds when a similar call via the REST API took 2-3 seconds. \ – Matt Lacey Sep 4 '15 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.