pass variable values to filter widgets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 06:49 AM
Hi Everone, we are trying to list the requested items for a particular user selected in order guide form in helsinki service portal. so basically we want to pass the employee name(referring to user table) to the filter of simple list widget, once the manager selects the employee name from dropdown which is order guide widget and display the requested items in 'simple list' widget. both the widgets are added in orderguide page. we have already gone through community page ". any other pointer would be high appreciated.
How to communicate between widgets in Service Portal
"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 06:35 AM
Thank jitendra, I am using two service portal widget one is order guide and simple list. change in value of variable in order guide should pass to simple list widget filter. please let me know if you think of different approach.
Regards
Bhanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2016 12:13 AM
Hi Bhanu,
Got it you want to filter List value in the Second Widget on the basis of passed value from first widget?
Please tell me if I'm correct.
Regards,
Jeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2016 12:35 AM
yes exactly from order guide widget to simple list widget filter..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2016 01:33 AM
Hi Bhanu,
Done with your requirement.
I'm Just posting the client and server script code for first and second widget just go thru this, This might help you.
Widget One : Passing text value on ng-click
HTML:
<input name="pid" id="pid" ng-model="pid" ng-click="selectItem(pid)"/> // PASS VALUE TO NG-CLICK , How to send value from ur text box or select box just manage to send
client script:
function($scope,$rootScope,$timeout) {
/* widget controller */
var c = this;
$scope.selectItem= function(selection){
alert(selection);
c.selectedItem = selection;
$rootScope.$broadcast('showHideWidget', selection);
};
}
Widget Two : Filtered table list on the basis of broadcast value.
HTML:
<tr ng-repeat="row in data.prods | filter : showWidget">
Server Script :
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.prods=[];
var sg = new GlideRecord('u_product');
sg.query();
while (sg.next()){
var product ={};
product.pid = sg.getDisplayValue("u_number");
product.pname = sg.getDisplayValue("u_product_name");
product.pcat = sg.getDisplayValue("u_category");
product.pquant = sg.getDisplayValue("u_quantity");
product.pamount = sg.getDisplayValue("u_total_amount");
product.pdesc = sg.getDisplayValue("u_short_description");
product.pvendor = sg.getDisplayValue("u_vendor");
product.ostatus = sg.getDisplayValue("u_order_status");
data.prods.push(product);
}
})();
Client Script :
function($scope, $rootScope) {
/* widget controller */
var c = this;
$scope.showWidget = "";
//Listening for "showHideWidget" event
$rootScope.$on('showHideWidget', function(event,data) {
$scope.showWidget = data;
alert(showidget);
alert(data);
});
}
If it is helpful guys please vote Thank you in Advance.
Regards,
Jeet.