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.

2
  • 1
    Can you please share sample code ? Aug 20, 2015 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, 2015 at 18:26

1 Answer 1

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);
});
2
  • 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, 2015 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, 2015 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .