pass variable values to filter widgets

bhanuprasad
Tera Contributor

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

"

orderguide.jpg

5 REPLIES 5

bhanuprasad
Tera Contributor

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


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


bhanuprasad
Tera Contributor

yes exactly from order guide widget to simple list widget filter..


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.