Getting list view results from jsforce

443 Views Asked by At

I'm able to get the results of a list view like so:

conn.sobject('ListView').retrieve(listId, function(err, listView) {
  console(listView);
});

But that only returns the description of the list view without the results and I want to get the results of the list view as well.

I see in the docs here that there is a ListView class that has a results method, but I can't figure out how to use it.

Is there something I am missing? thank you!

1

There are 1 best solutions below

0
On

The ListView in API reference is not a sobject name to pass Connection#sobject(sobjectName). It is a JavaScript class whose instance will be returned by SObject#listview(listviewId). The available listview definitions of certain SObject are returned by calling SObject#listviews().

conn.sobject("Account").listviews((err, ret) => {
    const listviewId = ret.listviews[0].id;
    conn.sobject("Account").listview(listviewId).results((err, res) => {
        console.log(res.records);
    });
});