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!
Rate this article:
Comments
filski
8 - Cloud Apps
8 - Cloud Apps

@intapiuser

This looks like it would be really useful. Could you please either allow access to the Google Drive file or set so permissions aren't restricted? Thanks, Philip. 

Version history
Last update:
‎02-16-2024 09:07 AM
Updated by: