Hi all, is there a way to populate an `AttributeFi...
# gooddata-platform
c
Hi all, is there a way to populate an
AttributeFilter
dynamically? I'm using the
Dashboard Component
from the
React SDK
, and I wonder if there's a way to accomplish something like this: Let's say I have 2 different users and I want their options on an Attribute Filter (
Clients
) to be different, e.g.:
User A
can see
Client A
,
Client B
and
Client C
and
User B
can see
Client D
,
Client E
and
Client F
. See image. Thanks.
j
Hello @Carlos Lozano! This is what GoodData does very well, but the concept is a bit different šŸ™‚ Let me explain: You will want to create a master workspace that contains all of your data (Clients A through F). Then you will want to create 2 child workspaces. Workspace A will have "workspace data filter" set to values Client A, Client B, and Client C. While workspace B will have workspace_data_filter set to Client D, Client E, and Client F. You will then invite User A to workspace A, and will invite User B to workspace B. When each user logs in, they will only see the respective filter values in their attributes. Makes sense? šŸ™‚ Here's the link for Workspace Data Filters. Good luck and let us know if there's anything else we can help with!
c
Thank you @Jiri Zajic. Maybe I missed some information on the application's flow, so I made another sketch. Basically: ā€¢ User log in through our web application (e.g. User A). ā€¢ After login we request to our back-end the clients this user can see or has access (e.g. Client A, Client B, Client C). ā€¢ We want to set this clients on an AttributeFilter so that the user can filter the embedded Dashboard.
@Shashank Banerjea you are welcome if you want to add something.
s
Thank you for the details. @Carlos Lozano. @Jiri Zajic - Thank you for your response. I work with Carlos with the dashboard application, we are trying to develop. The main goal is to be able to pass parameters to the dashboard component, which sits outside GoodData in our Application. Client ID is one example. It could be other parameters in the future.
j
Hello @Carlos Lozano and @Shashank Banerjea, thank you for the clarification! I think I understand the problem you are trying to solve and looking at the 2nd sketch my answer remains pretty much the same šŸ™‚ There is this collectLabeleElements API endpoint that returns available attribute values. Assuming User A has only access to Workspace A that has workspace-data-filters set to values Client A-C, then the endpoint will only return values Client A, B, and C. The same applies for User B that has access to Workspace B that has workspace-data-filters set to values Client D-F. This ā˜ļø would be a secure/restrictive way how to make sure your users cannot see some other data. If this is not the case and you are simply looking for a way to pre-filter the dashboard for user convenience, then it's much simpler. If you're embedding the Dashboard using an iframe, you can utilize window.postMessage commands to programatically filter a dashboard. If you're embedding the Dashboard using the
<Dashboard />
React component then you can programatically filter the dashboard by providing the filterContextRef property.
c
Thank you very much for your help @Jiri Zajic. We'll take a look at those links.