Technical Blog Post
Abstract
Solution to customize in-basket filter in ICM system
Body
Solution to customize in-basket filter in ICM system
Author: Gai Li(ligai@cn.ibm.com)
In this document, there are two solutions are introduced for in-basket filter setting up:
- Solution to apply in-basket filter at switching role
- Solution to Set in-basket filter field display none
Solution to apply in-basket filter at switching role
Steps:
step 1: add a script adapter, and wire it with Toolbar at Role selected event. Edit the script adapter to save current role name to a variable, like the code in blue shows.
dojo.setObject("customApp.currentRole", payload.name);
return payload;
step 2: add another script adapter and wire it with in-basket at incoming event in-basket selected and outgoing event Apply filter. Then provide your filter logic in script adapter, like the code in blue shows.
if (customApp.currentRole=="SimpleRole" && payload.currentInbasket=="SimpleRole")
{
dojo.setObject("customApp.currentRole", "");
var newpayload = {};
newpayload.inbasketName="SimpleRole";
newpayload.filters=[];
newpayload.filters[0]={};
newpayload.filters[0].name="Filter1";
newpayload.filters[0].value="Xiao";
return newpayload;
}
else if (customApp.currentRole=="SimpleRole2" && payload.currentInbasket=="SimpleRole2")
{
dojo.setObject("customApp.currentRole", "");
var newpayload = {};
newpayload.inbasketName="SimpleRole2";
newpayload.filters=[];
newpayload.filters[0]={};
newpayload.filters[0].name="Filter1";
newpayload.filters[0].value="Abc";
return newpayload;
}
step 3: hide above two script adapters, save the setting.
Solution to Set in-basket filter field display none
The steps:
1. Add ScripAdapter to page;
2. Wire Inbasket "inbasket selected" event with ScriptAdapter;
3. Add the following codes in ScriptAdapter.
console.log("Starting the function, resetFiler");
this._globalWidgetModel = com.ibm.mashups.iwidget.model.Factory.getGlobalWidgetModel();
/*Get all widgets in current page */
var wdgtIds = [];
for(var id in this._globalWidgetModel.getAllWidgets()) { wdgtIds.push(id); }
/* Go through all widgets in the page to get the first Inbasket widget */
var widgetWrapper = null;
for(var i = 0; i < wdgtIds.length; ++ i) {
widgetWrapper = this._globalWidgetModel.find(wdgtIds[i]);
if(widgetWrapper && widgetWrapper.widgetDef && widgetWrapper.widgetDef.widgetDef && widgetWrapper.widgetDef.widgetDef.iScope === "com.ibm.im.ecmwidgets.iwidget.Inbasket"){
break;
}
}
var iWidgetInstance = widgetWrapper;
if (iWidgetInstance) {
console.log("Get a inbasket widget instance, start to set a new filter and refresh the inbasket");
var inbasketIScope = iWidgetInstance.iScope._proxy;
/*Get the inbasket's filterPane object*/
var inbasketFilterPane = inbasketIScope.viewModeContentPane.queueElementGrid.filter.pane;
//console.dir(inbasketFilterPane ) ;
/*Set filter first field's domNode display none*/
dojo.style(inbasketFilterPane.form._fieldWidgets[0].domNode, "display", "none");
}return payload;
4. Click Inbasket tab to test.
UID
ibm11281772