Hi all, in an embedded dashboard using Iframe, we ...
# gooddata-cloud
g
Hi all, in an embedded dashboard using Iframe, we are using postMessage to send filters from our application to goodData dashboard. How can we know which date field to use as ID in the call? Since the dashboard can have more than one date field, should we retrieve all the date fields of a dashboard and apply them to date range filter (the default date filter for all dashboards) or how do we do this?
f
Hi Goran, if there are multiple date dimensions being used in the dashboard, you would have to add a filter to them separately. In this case, the rules described for Additional Date Filters in our documentation about Date Filters apply here. Do keep in mind the following limitation for setContextFilter, in case the dashboard already contains multiple date filters:
You are currently not able to change filter contexts with postMessages if the dashboard contains multiple date filters. We intend to implement a fix for this in the future.
From what I can find, it’s not possible to set the Primary Date Filter (the default one, that applies to every date dimension) via PostMessages.
g
Hi , @Francisco Antunes we don’t have multiple date filters, just the default date-range filter. This date-range filter has been configured to use three date dimensions (for example date1, date2 and date3). We are using postmessage to change the contextFilter and send date1 as ID, and the date-range filter is somehow affected and all data in the dashboard is filtered, which is what we need. But can we be sure that it will always work like this? The issue might be that date1 is changed and no longer configured with the date-range filter. If this is the case, should we then update the postmessage with date2 and so on? gdc: { product: "dashboard", event: { name: "setFilterContext", data: { filters: absoluteDateFilter: { dataset: { identifier: { id: "Date1", type: "dataset" } }, from: this.formatDate(dateRange[0]), to: this.formatDate(dateRange[1]) } } } }
f
Hi Goran, sorry about the delay here. We’re still working on testing out the postMessage for the Date filters to best understand this behavior. We’ll be back with an update soon!
Hi @Goran Jakimovski, whilst I’m still working on adding individual filters for date dimensions via postMessage, I figured out how to apply a new Date to the Primary Filter (the one that applies to all dimensions). All you need to do is not include the
dataSet
object in your JSON. Something like this:
Copy code
{
  "relativeDateFilter": {
    "from": 0,
    "to": 0,
    "granularity": "GDC.time.week_us"
  }
}
This set the default date filter to this week. Would you kindly give that a shot and let us know if it works?