I want to create a module with a dynamic filter for the user table.

bonsai
Mega Sage

I have created a custom field A in the user table.

*Custom field is a string.

Create a module for the user table.

Set a filter condition in the module: "Show records that have the same value as custom field A for the logged-in user."

How can I set this?

1 ACCEPTED SOLUTION

Dnyaneshwaree
Mega Sage

Hello @bonsai,

As per information you have provided,

You have created a custom field A in the user table. And Custom field is a string.

You need to Create a module for the user table and want to Set a filter condition in the module: "Show records that have the same value as custom field A for the logged-in user." for that you can follow below steps:
Navigate> System Definition > Application Menus>User Administration (as per your choice)>Modules > New >fill other info including table = sys_user and Link type = List of Records > Filter ex. "A is javascript:gs.getUser().getRecord().getValue('A')." 
Dnyaneshwaree_0-1722838833021.png

You need to create dynamic filter to add condition so you can refer below articles for the same:
https://www.servicenow.com/community/developer-forum/how-to-create-a-module-that-filters-by-dynamic-...
https://www.servicenow.com/community/now-platform-forum/how-to-use-dynamic-filters-on-modules/m-p/11...
https://www.servicenow.com/community/now-platform-forum/how-to-use-dynamic-filters-on-modules/m-p/11...
https://www.servicenow.com/community/developer-forum/how-to-make-a-dynamic-filter-available-for-some...


 

 

 

 

View solution in original post

2 REPLIES 2

Dnyaneshwaree
Mega Sage

Hello @bonsai,

As per information you have provided,

You have created a custom field A in the user table. And Custom field is a string.

You need to Create a module for the user table and want to Set a filter condition in the module: "Show records that have the same value as custom field A for the logged-in user." for that you can follow below steps:
Navigate> System Definition > Application Menus>User Administration (as per your choice)>Modules > New >fill other info including table = sys_user and Link type = List of Records > Filter ex. "A is javascript:gs.getUser().getRecord().getValue('A')." 
Dnyaneshwaree_0-1722838833021.png

You need to create dynamic filter to add condition so you can refer below articles for the same:
https://www.servicenow.com/community/developer-forum/how-to-create-a-module-that-filters-by-dynamic-...
https://www.servicenow.com/community/now-platform-forum/how-to-use-dynamic-filters-on-modules/m-p/11...
https://www.servicenow.com/community/now-platform-forum/how-to-use-dynamic-filters-on-modules/m-p/11...
https://www.servicenow.com/community/developer-forum/how-to-make-a-dynamic-filter-available-for-some...


 

 

 

 

Setting the script in the arguments field solved it!
Thanks!