0

I am looking to provide a mechanism that uses the filter part of list views to filter a graphical representation of various (custom or standard) objects. I want the user to be able to select any existing list view they have, using a drop list, for a given object that is being graphically represented in our custom LWC. These list views would be those that are shared (by themselves or others) and those that are private to them.

That means I need a way to get a list of the user's list views for a given object.

I've been researching how I might do this and have found:

  1. The metadata API allows access to a list of list views, but this excludes "Visible only to me" list views.
  2. The lightning/uiListsApi wire services module allows access to the detail of a named list view, so I can build the required filter query, but has no mechanism for discovering the list views the user has access to.

This leaves a gaping hole where I cannot discover the user's available list views since many of these would be "Visible only to me" restricted.

Is there a mechanism I can use (ideally from Apex, but at a push from LWC) to get the list of list view API names for a given user including their "private" ones?

If not, is this suggesting that Salesforce do not recommend trying to use list views to achieve the sort of use case solution I've outlined, above?

1 Answer 1

0

There's a REST API, part of the UI API, that allows fetching the list views for an object, with a REST resource of the form:

/ui-api/list-ui/${objectApiName}

Clearly the disadvantage here is that this is not a programmatic API, but rather a REST API, so to use it from Apex (or LWC) requires ensuring the org's APIs to be set as a remote site (or CSP trusted site) and for a callout (or fetch) to be made. This is a common workaround to lack of APIs in Apex, though should always be done with care since re-entrancy to the org from itself can lead to problems like self-deadlock etc.

The response contains a property called lists that is an array of List View Summary values, each having the required apiName and label needed for use in the UI and for passing to the lightning/uiListsApi.

You must log in to answer this question.

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