cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Part 1: Preparation And Setup
  1. Download the BloX Template Here
  2. Import the Template into BloX (tutorial here)
  3. Create an action called "RelativeDate"
  4. Add the code below to the action and save it.
if (payload.text == "Year" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "years";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 0;

 

} else if (payload.text == "Qtr" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "quarters";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 0;

 

}  else if (payload.text == "Month" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "months";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 0;

 

} else if (payload.text == "LastMonth" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "months";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 1;

 

}  else if (payload.text == "Week" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "weeks";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 0;

 

} 

 

//Add widgetsIDs that you would like to update

var widgets = ['5efb8c3ad957252878a2bb7d','5efb8c5dd957252878a2bb7f'] //Apply this action on widget ids

 

//for each widget id

widgets.forEach(myfunction)

function myfunction (item)

{

var widgetfindid = prism.activeDashboard.widgets.$$widgets.find(w => w.oid === item)

widgetfindid.changesMade() //apply changes to Mongo

widgetfindid.refresh() //refresh the widget

 

}
CONFIGURATION STEP A: DEFINING FILTER
Add a filer on a Date Dimension using the “Time Frame”  option.
STEP B: CONFIGURING YOUR ACTION
The action has this format:
This code is in the blox “Editor” section. Add the items you want to filter on.
"type": "ActionSet",

                    "actions": [

                        {

                            "type": "RelativeDate",

                            "text": "Week",

                            "title": "Current Week"

                        },

                        {

                            "type": "RelativeDate",

                            "text": "Month",

                            "title": "Current Month"

                        },
This code is in the action. Add the “if” portion to correspond with the “ActionSet”.
if (payload.text == "Year" ) {

 

prism.activeDashboard.filters.$$items[0].jaql.level = "years";

prism.activeDashboard.filters.$$items[0].jaql.filter.last.count = 1;

prism.activeDashboard.filters.$$items[0].jaql.filter.last.offset = 0;

 

} else if
--- See the code in the action
Apply and enjoy!
Version history
Last update:
‎03-02-2023 08:31 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

Sisense Privacy Policy