Post widget JAQL and Refresh Embedded Widget to show results



  • Avatar
    Moti Granovsky

    Hi David!

    JAQL is just the syntax for querying data - it is not inherently bound to any specific widget or dashboard, which in turn means that executing any JAQL query has no affect on any widgets or dashboards, just like executing a SQL query against MySQL would not affect any web components that visualize data based on that same MySQL.

    To make a widget show data from a different query, you need to update that widget's metadata. and then refresh it. But before diving into how that's done, it's important to clarify your last sentence: "just for the local user":

    • if you mean the changes should be applied only to one given user and not other users who can view the same dashboard, but persisted for these users, hen you do want to have those changes saved. Each user has their own instance of a dashboard - and changes they make are not reflect to other user, with the exception of the dashboard's owner who can make changes and re-publish the dashboard to apply these changes to all users with whom the dashboard is shared.
    • If you mean these changes should apply only immediately, for a given person looking at the widget, and not persist upon refresh of the page, then you would make changes to the widget's metadata  on the client side (no REST calls required) and make it reload, and below is an example of how that can be done

    And this is a simple and crude example of how you could change a widget's metadata in runtime and make it re-render with new data, on client only:

    prism.on('beforemenu', (ev, args) => {
    // we want to add an item to a specific menu - widget in dashboard
    if ( === 'widgetindashboard') {
    // save the widget instance to use in the closure
    const widget = args.settings.scope.widget;
    // add a button to the menu
    command: {
    title: 'Remove brand',
    canExecute: () => { return true; },
    execute: () => {
    // Get the columns panel
    const panel = widget.metadata.panel('columns');
    // Find the index of the 'brand' column in the panel
    const idxToRemove = panel.items.findIndex(i => i.jaql.title == 'Brand')
    // remove the item
    panel.items.splice(idxToRemove, 1)
    // refresh the widget, without saving these changes

    In this example the change is done via a menu item added to the "widgetindashboard" menu but of course as long as you have the widget object accessible you could implement similar logic anywhere else.

    Comment actions Permalink
  • Avatar
    David Phenicie

    Hello Moti, Thanks for your response. This does clear some things up for me... The method I am trying to achieve is what you described in your second bullet point. The change does not need to persist anywhere. I am going to attempt to implement your suggestion. While I am getting started, I have a few questions to make sure I understand;

    1. Is prism a variable name that is a reference to the sisense dashboard?  We are using sisense.js to connect to our dashboard. I have seen prism referenced before, but not sure where this comes from. We are not currently using any prism objects that i know of.

    2. Whenever I update the jaql within the metadata of a widget, calling refresh on that widget will re-query the data store using the new structure described in the new jaql query, is this correct?

    Thanks again

    Comment actions Permalink

Please sign in to leave a comment.