The Zurich release has arrived! Interested in new features and functionalities? Click here for more

filter incidents by logged in user region

gnani
Mega Expert

Hi All,

I am trying to filter the incidents by logged in user region, I am trying to use a dynamic filter to achieve this. But i am unable to find the user region in the relates list fields.

Please help me !!

Thanks,

Nani.

12 REPLIES 12

Chuck Tomasi
Tera Patron

Hi Nani,



I would approach this by creating a script include that does a lookup of the current user's record and return the region, then call your script include from the dynamic filter. Note: All code below is untested and may require adjustments to work on your system.



E.g.


var getMyUserInfo = Class.create();


myConditionCheck.prototype = {


      initialize: function() {


      },



        myRegion : function() {


                var user = new GlideRecord('sys_user');


                if (user.get(gs.getUserID()) {


                          return user.u_region;


                }


                return;


        },



      type: 'myConditionCheck'


};



Your dynamic condition would then contain




new getMyUserInfo().myRegion();


Hi Chuck,



But then how can we link the dynamic filter to the incident module?? Does the dynamic filter show up in the related list in the filter conditions??



Thanks,


Nani


Hi Nani,



I'm going to assume you mean you want to click here:


find_real_file.png



And want a filtered list to appear based on some field value (e.g. Region (u_region)) in the incident record. Please clarify if my assumption is incorrect.



First, navigate to System Definition> Application Menus


Open the Service Desk record and go to the related list of modules at the bottom of the form.


Locate the Incidents record and open it.


Change the record so Link type is set to URL from arguments and Arguments points to the URL including a call to the script.



find_real_file.png



This link may help.


http://wiki.servicenow.com/?title=Navigating_by_URL


I have to create a incident module under incident application which filters the incidents based on the logged in user region. To do this i have created a script include and a dynamic filter, also i have attached script include to the dynamic filter. But then i am not seeing the (is Dynamic) option in the related list in the filter condition in the incident module which i am trying to create.  



I think this clarifies your doubr