Is it possible to retrieve Variables when using Bricks?

Brand new to Bricks here. If we add a variable to a dashboard that should change the behavior of all cards including a brick, can we check the value for that variable in the Javascript section to so we can adjust our query or logic accordingly?

I saw in this video that you can add controls to the brick itself, but was wondering if the brick can leverage the controls that have been added to the Dashboard instead, if so how?

https://www.youtube.com/watch?v=15nXTopnRcI&t=605s

Not really sure where to find all the information on what is available as part of the domo object and what data can we expect to find in it, like I saw you can use the filterContainer one to pass a filter to the dashboard, but not sure if you could retrieve the variables that have been overwritten this way or not (I tried sending a variable as a pfilter in the past but didn't managed to make it work).

Thanks,

Best Answer

  • rileystahura
    rileystahura Admin
    edited March 2023 Answer ✓

    hello @marcel_luthi .

    First I want to clarify for some that might read this thread thinking we are talking about the Variables product.

    https://domo-support.domo.com/s/article/7903767835031?language=en_US

    Bricks and Custom Apps do NOT work with the Variables product and there is no current workaround. Now when you're not talking about the Domo Variables product, but just talking about a passing data from one brick to another brick or another dashboard, there's one approach that comes to mind. One very common use case is the need to persist filters from one dashboard to another. This is accomplished using a combination of domo.onFiltersUpdate() and appDB.

    The steps could look like this:

    1. The app/brick exists on both Dashboard 1 and Dashboard 2
    2. The app uses domo.onFiltersUpdate() (https://developer.domo.com/portal/e947d87e17547-domo-js) to listen for page filters being added/removed on the page
    3. Whenever that listener triggers, you can store the filters in a javascript variable
    4. Write the data in that variable to an appDB collection
    5. Navigate to new dashboard
    6. On initial render, that brick, the same brick that was on the first dashboard, reads from appDB to find the filters that you previously wrote to appDB.
    7. It then uses domo.FilterContainer() to apply page filters on the new page

    There are other things you'd have to catch and account for, like avoiding a permanent loop of writing to appDB then reading to appDB then applying filters then writing to appDB etc.

    Similarly, if you have 2 bricks and you want some action you take in brick 1 to change behavior in brick 2, you can use appDB to pass those values to the other brick.


    Here is the appDB documentation: https://developer.domo.com/portal/1l1fm2g0sfm69-app-db-api

Answers

  • rileystahura
    rileystahura Admin
    edited March 2023 Answer ✓

    hello @marcel_luthi .

    First I want to clarify for some that might read this thread thinking we are talking about the Variables product.

    https://domo-support.domo.com/s/article/7903767835031?language=en_US

    Bricks and Custom Apps do NOT work with the Variables product and there is no current workaround. Now when you're not talking about the Domo Variables product, but just talking about a passing data from one brick to another brick or another dashboard, there's one approach that comes to mind. One very common use case is the need to persist filters from one dashboard to another. This is accomplished using a combination of domo.onFiltersUpdate() and appDB.

    The steps could look like this:

    1. The app/brick exists on both Dashboard 1 and Dashboard 2
    2. The app uses domo.onFiltersUpdate() (https://developer.domo.com/portal/e947d87e17547-domo-js) to listen for page filters being added/removed on the page
    3. Whenever that listener triggers, you can store the filters in a javascript variable
    4. Write the data in that variable to an appDB collection
    5. Navigate to new dashboard
    6. On initial render, that brick, the same brick that was on the first dashboard, reads from appDB to find the filters that you previously wrote to appDB.
    7. It then uses domo.FilterContainer() to apply page filters on the new page

    There are other things you'd have to catch and account for, like avoiding a permanent loop of writing to appDB then reading to appDB then applying filters then writing to appDB etc.

    Similarly, if you have 2 bricks and you want some action you take in brick 1 to change behavior in brick 2, you can use appDB to pass those values to the other brick.


    Here is the appDB documentation: https://developer.domo.com/portal/1l1fm2g0sfm69-app-db-api

  • Thanks, I was talking about the functionality between the two products: Bricks and Variables, so thanks a lot for the clarification. The additional information will certainly come in handy for other use cases.