Leveraging Global Relational Variables insights for Enhanced Dashboard Filtering

I’m currently working on a dashboard in Directus and looking to enhance its functionality. The challenge I’m facing is that when I select an item using a global relational variable, I only receive the ID of that item. However, I need to access the entire set of fields associated with that item to use them for filtering in another panel.

For instance, when I select an item from a collection, I want to retrieve various fields (like field1, field2, etc.) from that item and use them to filter data in another panel. This would allow for more dynamic and relevant visualizations based on the selected item.

Request for Recommendations

I’m reaching out to the community for recommendations on how to achieve this. Specifically:

  • What would be the best approach to access the full fields of a selected item within a custom panel?
  • How can I ensure that these fields are available for use as filters in other panels?

I appreciate any insights, examples, or best practices you can share.

1 Answer

1

Hey Nima,

Good question! Seems like the standard option only returns an ID.
Inside a custom extension, you could easily do this.
As an example you can use the current panel of Directus:

Seems like this line is being used for setting the variable data:

I've been implementing a date range picker for Directus Insights. The emit approach isn't working - when I use {{date_range}} in a label, it shows undefined. The community shared how the official relational-variable panel uses useInsightsStore().setVariable(), but that's not available in the extensions SDK. With variable: true defined in our panel, we still don't have a working method to set dashboard variables. How can custom panel extensions actually set variables without access to the internal insightStore? Is there an alternative API or pattern?

Not "easily" at all, the SDK doesn't provide access to tons of foundational objects required for this to work, unless the whole directus project is forked, we don't see an easy way, maybe we are lost on the approach. We just need to add a "default" value to avoid the related chart to be empty when the user has not selected a value.