cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
This article details the process of creating a BloX button that applies/removes Break By on one or more widgets. 

Step 1

Create the widget(s) including the Break By field. We will need to retrieve the JAQL for the Break By field and add it later via a custom BloX action. 

Step 2

After creating the widget, open up the developer console and type:
prism.activeDashboard.widgets.$$widgets
All widgets in the dashboard will be displayed. Identify the target widget by title or subtype. Take note of the index (in this example, the index=7).
Navigate to:
prism.activeDashboard.widgets.$$widgets[7].metadata.panels
Select the Break By panel (it is the index 2 below). Open it and navigate to:
items[0].jaql
Copy the JSON of the JAQL. This is what we will be injecting with the BloX custom action. 

Step 3

Create the BloX widget. Here is a simple example with an action set button:
{
"style": "",
"script": "",
"title": "",
"showCarousel": true,
"body": [
     {
     "type": "Container",
     "items": [
          {
          "type": "ActionSet",
          "actions": [
               {
               "type": "Total/BreakBy",
               "title": "Total/Break By"
               }
           ]
          }
         ]
      }
],
"actions": []
}

Step 4

Create the custom BloX action. In the example, it is called 'Total/BreakBy'. 
Please Note: You will need to change the index in the following line to match the index found in Step 2. If you would like this script to affect multiple widgets, you can add more than one index, separated by commas. 
var widgetIndexArray = [7];
You will also need to replace the JSON in the 'jaql' variable below with the JSON copied in Step 2.
//Variable that stores all widgets that sound be affected
var widgetIndexArray = [7];
//Variable that stores the JAQL to add
var filterJAQL = {
jaql:{
column: "Item",
datatype: "numeric",
dim: "[Exports.Item]",
table: "Exports",
title: "Item"
}
}

//Loop through the widgetInsexArray
for(var i = 0;i<widgetIndexArray.length;i++){
     //Get the widget index that corresponds to the index
     var widgetOID = widgetIndexArray[i];
     //Get the widget object
     var widget = prism.activeDashboard.widgets.$$widgets[widgetOID];
     if(typeof widget.metadata.panels[2].items[0] === 'undefined') {
          // does not exist
          widget.metadata.panels[2].items.push(filterJAQL)
     }
     else {
          // does exist
          widget.metadata.panels[2].items.shift()
     }

//refresh the widget
widget.refresh()
}
That's it! The button should now add/remove the Break By for the dashboard widget. 
Rate this article:
Comments
liamcameron
8 - Cloud Apps
8 - Cloud Apps

i want 4 buttons, that change the breakby to different values... could this solution be extended to do so?! could you help explain how?!

Version history
Last update:
‎03-02-2023 08:34 AM
Updated by:
Contributors