Programmatic Filters Implementation Help

ekishab
ekishab Member
edited April 2023 in Domo Everywhere

Hi, I'm using programmatic filters for the first time. This image below is on Domo's documentation - https://developer.domo.com/portal/1yafxad1u8azv-programmatic-filtering#linking-across-embedded-dashboards-while-persisting-programmatic-filters . I created a similar file in my code base but I'm not sure what visualization1 is? Is it the name of the dashbord? Where is it defined? Additionally, how is this called in the frontend? Do I need to do anything on the frontend for this to work, for eg: any fields in the iframe tag?

Best Answer

  • nikky
    nikky Member
    Answer ✓

    @ekishab, thanks for your question!

    Context:

    With programmatic filters and dashboard / card embed, your web page will have a dashboard / cards embedded into it by way of an iFrame.

    Depending on who is logged into your Web portal / page they may see a sales dashboard / card in the first iFrame and an marketing dashboard / card in a second iFrame - each of the dashboards in DOMO will have it's own associated Embed ID.

    For user Mike - viz 1 may be the Sales with its own set of filters and viz 2 the marketing with its own set of filters.

    For user Suzanne viz 1 may be the Sales with a different set of filters to Mike and viz 2 the marketing with its own set of filters.

    etc.

    Code

    Looking at the sample.html that came with the code:

    <iframe id="iframe1" src="/embed/items/1" width="100%" height="100%" scrolling="no" style="border: none"></iframe>

    The source is pointing to the first vizualization in the Users.js file for this user (item/1).

    This is handled in the express.js file with the Item/1 passed in from the iFrame:

    app.get('/embed/items/:itemId', passport.authenticationMiddleware(), (req, res, next) => { const config = req.user.config['visualization'+req.params.itemId]; if (config.embedId) { embed.handleRequest(req, res, next, req.user.config['visualization'+req.params.itemId]); } else { next(`The EMBED_ID${req.params.itemId} environment variable in your .env file is not set. Please set this in order to view content here.`); }});

    Conclusion

    For mike, the iFrame will return the Sales dashboard / card with a set of filters applied.

    For Suzanne, the Sales dashboard / card will be returned with a different set of filters applied.

    You need to ensure that the Users.js file is populated with the correct embed Ids, filters & credentials for the iFrame to be able to retreive the correct visulization for the specific user.

Answers

  • nikky
    nikky Member
    Answer ✓

    @ekishab, thanks for your question!

    Context:

    With programmatic filters and dashboard / card embed, your web page will have a dashboard / cards embedded into it by way of an iFrame.

    Depending on who is logged into your Web portal / page they may see a sales dashboard / card in the first iFrame and an marketing dashboard / card in a second iFrame - each of the dashboards in DOMO will have it's own associated Embed ID.

    For user Mike - viz 1 may be the Sales with its own set of filters and viz 2 the marketing with its own set of filters.

    For user Suzanne viz 1 may be the Sales with a different set of filters to Mike and viz 2 the marketing with its own set of filters.

    etc.

    Code

    Looking at the sample.html that came with the code:

    <iframe id="iframe1" src="/embed/items/1" width="100%" height="100%" scrolling="no" style="border: none"></iframe>

    The source is pointing to the first vizualization in the Users.js file for this user (item/1).

    This is handled in the express.js file with the Item/1 passed in from the iFrame:

    app.get('/embed/items/:itemId', passport.authenticationMiddleware(), (req, res, next) => { const config = req.user.config['visualization'+req.params.itemId]; if (config.embedId) { embed.handleRequest(req, res, next, req.user.config['visualization'+req.params.itemId]); } else { next(`The EMBED_ID${req.params.itemId} environment variable in your .env file is not set. Please set this in order to view content here.`); }});

    Conclusion

    For mike, the iFrame will return the Sales dashboard / card with a set of filters applied.

    For Suzanne, the Sales dashboard / card will be returned with a different set of filters applied.

    You need to ensure that the Users.js file is populated with the correct embed Ids, filters & credentials for the iFrame to be able to retreive the correct visulization for the specific user.