Forum Discussion
HI keerthan thanks for suggestion, although it is going to be tricky for me. Need to write new custom action based on the one I had written by another dev and include now functionality from build in filter action.
Is there no option for one action to trigger another one in other words is it possible to create custom action which will take other actions as parameters?
Thanks,
Wojtek
- keerthan09-13-2022Cloud Apps
Wojtek I don't think we have that option for 'Custom Actions'. But I can help you with the script if you elaborate more on the requirement
Thanks & Regards
Keerthan
- Wojtek09-14-2022Cloud Apps
HI keerthan
Appreciate your help on this, hopefully other will benefit from it too.
I attached template for my blox with 2 buttons.
First button is using custom action SwitchPanelItem which swaps items from this blox to destination blox by panel and item number. Im using it to change granularity here. whats important it can modify any number of widgets (3 in this example):
{ "type": "switchPanelItem", "title": "Day Granularity", "style": { "width": "150px", "background-color": "#a6a6a6" }, "data": { "actionDetails": [ { "targetWidget": "630cb7bf6c6a680037e5dc99", "sourcePanel": "0", "sourceItem": "0", "destPanel": "0", "destItem": "1", "dimName": "Date" }, { "targetWidget": "630cb7bf6c6a680037e5dca3", "sourcePanel": "0", "sourceItem": "0", "destPanel": "0", "destItem": "0", "dimName": "Date" }, { "targetWidget": "630cb7bf6c6a680037e5dc95", "sourcePanel": "0", "sourceItem": "0", "destPanel": "0", "destItem": "0", "dimName": "Date" } ] } }The second action is standard filter action to modify dashboard date filter, in this example changing it to last 8 days:
{ "type": "Filters", "title": "dashboard filter - last 8 days", "style": { "width": "220px", "background-color": "#a6a6a6" }, "data": { "level": "days", "filters": [ { "filterName": "History", "filterJaql": { "last": { "count": 8, "offset": 0 } } } ] } }also here is switchPanelItem action code:
payload.data.actionDetails.forEach(function (a) { var w = payload.widget.dashboard.widgets.$$widgets.filter(i => i.oid == a.targetWidget)[0]; w.metadata.panels[a.destPanel].items[a.destItem].jaql = JSON.parse(JSON.stringify(payload.widget.metadata.panels[a.sourcePanel].items[a.sourceItem].jaql)); if (typeof a.dimName == 'string') { w.metadata.panels[a.destPanel].items[a.destItem].jaql.title = a.dimName; }; w.changesMade(); w.refresh(); });The challenge is to make those 2 actions into one so they can be executed with single button. Important is to be able to switchPanelItems for any number of widgets.
Again, thanks for your help on it.
Wojtek