I need to send a lot of dashboards with differents...
# gooddata-cloud
g
I need to send a lot of dashboards with differents filters to differents e-mails. I want to make an automation for this. How can I filter the dashboards with the Python SDK? The documentation that I saw just shows how to export the dashboard without filters. Thanks!
🥲 1
j
Hello Guilherme, There was a previous thread in the gooddata-ui channel which touches on the topic: https://gooddataconnect.slack.com/archives/C01UR5BGAHY/p1715004413608909?thread_ts=1714999626.147219&cid=C01UR5BGAHY, could you review this and let us know if it fits in your usecase?
👀 1
g
I am trying do something different I think. Basicaly I need to send monthly dashboards from randoms customers. So, It is something like: 1. Connect to Python SDK/API with some external code; 2. Filter one by one the 100 customers; 3. Get the entire dashboard in PDF format; 4. Send to the customer via e-mail.
Anyone to help, please?
i
Hi Guilherme, How would you like to specify these filters, please? Do I understand it correctly, that you’d like to filter out only subset of data per recipient, based on selected Dashboard filter value? Have you considered to work with User Data Filters (UDF) (or with Workspace Data Filters (WDF) if you are working with multitenant setup)?
🤔 1
g
Basically I want to send a dashboard the same style when I filter inside the web plataform. So I do need filter de customer by id and send for respective e-mail. The problem is this customer isnt a BI user.
b
Hello Guilherme, As far as I can see here: https://www.gooddata.com/docs/python-sdk/latest/execution/exports/export_pdf/ the
export_pdf
method currently does not support using and setting the filter values. I reached out to our developers and they are currently reviewing the option of adding this feature. In the meantime, I found a possible workaround -> using the following API calls: https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/createPdfExport followed by: https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/getExportedFile With that in mind, you can for example "wrap" the calls by using the
requests
or some similar package(s): https://requests.readthedocs.io/en/latest/ I hope that it helps. 🤞🤓
🙌 2
Hello @Guilherme Silva, I would like to inform you that our developers were able to quickly add support for using and setting filters via the
export_pdf
method. The change has been included in the version 1.24.0, which was released last week: https://github.com/gooddata/gooddata-python-sdk/releases/tag/v1.24.0 It can be done by using the
metadata
parameter in the same way as if it were via the API call.
🙌 1
g
Thank you everybody for the replies. I hope you all have a great week!
e
Hey @Branislav Slávik , can you give an example of how an API call (with specific filters) can look like? Do we need to get the
filter_context
id and/or the
localIdentifier
? 😊
b
Hello @Evangelos Malandrakis, Apologies for the delayed response. For reference, a screenshot of my test dashboard with the filters setup is attached. The python code snippet example for the export is as follows:
Copy code
from gooddata_sdk import GoodDataSdk
from pathlib import Path

profiles = Path("profiles.yaml")
sdk = GoodDataSdk.create_from_profile(profile="bsla.cloud", profiles_path=profiles)


sdk.export.export_pdf(
        workspace_id="....", 
        dashboard_id="....",
        file_name="test",
        metadata={"filters":[{"dateFilter":{"granularity":"GDC.time.date","type":"absolute","from":"2020-03-24 00:00","to":"2025-04-24 23:59"}},{"attributeFilter":{"attributeElements":{"uris":["James","Jane"]},"displayForm":{"identifier":"NAME","type":"displayForm"},"negativeSelection":False,"localIdentifier":"465a183c6cab4bf4ad9783760cc21bc0","selectionMode":"multi"}}]}
        )
In this case, the
localIdentifier
was required. I would say that the best way to get the correct metadata would be to execute the export manually via the UI and then get the
metadata
based on the particular
exportId
by sending a GET request to the following endpoint: https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/getMetadata I hope it helps... 🤞 🤓
e
I'll have a look and let you know if I face any difficulties @Branislav Slávik, thanks!