Can you import /export a filter so It can be shared between users?

patrickw99
Kilo Contributor

I have a series of 5 filters that I need to give to about 20 different users.     Is there a way to share or import a filter so the other users can use them.     I just do not want to recreate all the filters on each users. I have tried to have them recreated on several users but it was hard to manually recreate each filter on each user account.  

8 REPLIES 8

chrishenson
ServiceNow Employee
ServiceNow Employee

Hello Patrick,



If you expand the filter conditions on any list there is an option to save the filter.   You can choose to save for just you, everyone or for a specific group.



If you have a subset of users to share the filter with I'd recommend creating a group for these users and then save the filters for that group.



Regards,



Chris


F.Y.I. The filters will then be available from the hamburger icon next to the table name for the users.


Vineetha Rohra1
Giga Guru

You can create your custom filter and later use it on user table.



Regards,



Vineetha


larstange
Mega Sage

Hi Patrick



The filters are stored in a table under System Definition -> Filters.


To copy a filter to another user, you simply open that specific filter, change the user and then right click the header and select insert and say. You repeat this for every user.


That could take some time if you have many filters for many users. Alternativley you could create a background script (or Fix Scripts - ServiceNow Wiki ) which does it for you



var filters = ["001e7d8e6f71c2806a1a08c6eb3ee42f","02ea3d05db3f1200a6f7ffa9bf96193c","037a59436f1d5640ad54b1b3dd3ee4d8"]; //Array of filters to copy by their id


var users = ["abc","efg","xxx"];// Array of user to copy to by their user_name



for (var i = 0; i < filters.length; i++) {


        var gr = new GlideRecord('sys_filter');


        gr.get(filters[i]);


       


        var newFilter = new GlideRecord('sys_filter');


        for (x = 0; x < users.length; x++) {


                  newFilter.initialize();



                  var user = new GlideRecord('sys_user');


                  user.get('user_name',users[x];


                  newFilter.user = user.sys_id;


                  newFilter.title = gr.title;


                  newFilter.table = gr.table;


                  newFilter.filter = gr.filter;


                  newFilter.insert();


        }        


}



The script has not been tested