top of page

Understanding Sisense Events





Leveraging Sisense Events

Sisense events are notifications that are generated when certain actions occur in Sisense, such as when a dashboard is loaded, a widget is refreshed, or a filter is changed. Events can be used to trigger custom JavaScript code, which can be used to perform a variety of tasks, such as updating other widgets, sending email notifications, or integrating with external systems.


There are three main types of Sisense events:


Widget events:

These events are generated by individual widgets, and they are generally related to the state of the widget, such as when it is refreshed, builds the query, or rendered.


Some common examples of widget events include:


  • initialized: Fired after the dashboard is initialized.

  • buildquery: Fired when executing the widget's native build query and allows customization of the JAQL query object before execution.

  • processresult: Fired when executing the widget's native result processing, and allows customization of the query result before being rendered.

  • render: Fired when the widget is rendered.

  • ready: Fired when the widget's rendering is over and the widget is ready.

  • beforedatapointtooltip: Fired for all widgets that render a tooltip.



Dashboard events

Dashboard events are triggered when certain actions occur on the dashboard level, such as when it is loaded, refreshed, or filter is changed.


Some common examples of dashboard events include:


  • initialized: Fired after the dashboard is initialized.

  • refreshstart: Fired after one or more widgets have started the refresh process.

  • widgetrefreshed: Fired when a widget refresh has ended.

  • filterschanged: Fired when the dashboard filter changes.

  • widgetprocessresult: Fired after executing the widget’s native result processing, and allows customization of the query result before being rendered.


Global Events

Sisense global events are a special type of event that can be triggered from anywhere in the Sisense web client. They are useful for performing tasks that need to be done regardless of which dashboard or widget is currently active.


Some common examples of global events include:


  • apploaded: Fired when the whole Sisense web application is loaded.

  • beforemenu: Fired before every menu is opened and allows the removal of existing menu items and the addition of custom menu items.

  • beforewidgetmenu: Fired when clicking the widget menu while in Edit Widget mode.

  • homeloaded: Fired when the home page in the Sisense Web Application is loaded.

  • dashboardloaded: Fired when a dashboard model is loaded into the environment.



How to use Sisense events

To listen for events, you can use the dashboard.on() , widget.on(), prism.on() methods. These methods take the event name as a parameter and a callback function that will be executed when the event is generated.


For example, the following code will listen for the dashboard.initialized event and log a message to the console when the dashboard is loaded:


dashboard.on('initialized', function() {

  console.log('Dashboard is loaded');

});



The following code will listen for the widget.render event and log a message to the console when the widget is rendered:


widget.on(render, function() {

  console.log(Widget  is rendered);

});


The following code snippet shows how to register a custom script to be triggered when a menu it opened:


prism.on(beforemenu, function() { 

// Perform some action when a menu is opened. 

});



Where to Write Code

To write JavaScript script code at widget level in Sisense, you can use the Edit Script option available in the widget menu. To open the widget edit menu, click on the Edit (pencil) icon in the top-right corner of the widget and click on 3 dots at the top right corner of the widget in edit mode.


To write JavaScript script code at dashboard level in Sisense, you can use the Edit Script option available in the dashboard edit menu. To open the dashboard edit menu, click on the 3 dots in the top-right corner of the dashboard.


The most optimal location for crafting global events is within a plugin. Plugins offer the capability to design solutions that manage global events seamlessly.


Streamlining Workflows with the Widget Script Manager Plugin


One of the challenges designers and administrators often face is managing scripts across multiple widgets, especially when these scripts are used across various widgets of the same type or specific dashboards. This is where the WidgetScriptManager plugin comes into play. It is designed to simplify the process of managing scripts for various widgets and dashboards, this plugin offers a centralized repository for scripts and comes equipped with a wealth of pre-built, handy widget scripts.


Key Features of Widget Script Manager


  • Free handy scripts example.

  • Easily decide on which widget you would like to deploy the code based on:

  • Specific widget

  • All widgets from a specific type

  • All widgets on specific dashboard

  • Any combination of the above

  • For example, you can trigger a script to run on a specific set of widgets within a specific dashboard.

  • Prevent widgets scripts discrepancies between dashboards.

  • Save time of developing and deploying your widgets scripts.

  • Enjoy the benefits of a plugin while keeping the flexibility of the widget scripts.

  • Can be easily integrated within your Git repository.


Ready to streamline your script management and unlock the potential of handy widget scripts? Check out Paldi's Widget Script Manager for more information


69 views0 comments

Comments


Check back soon
Once posts are published, you’ll see them here.

Similar posts

bottom of page