How to set a filter as default filter for everyone on workspace

Priya Singh 2 2
Tera Contributor

Hi Team,

I have to set filter - Active is true, and task assign to me

another one active is true and task assign to my group

I want to set these filters as default filter for everyone so whenever anyone clicks on task assign to me, task assign to my group relevant data should be populated in workspace view

How can I do that ?

 

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @Priya Singh 2 2 

 

https://docs.servicenow.com/bundle/vancouver-it-service-management/page/product/service-operations-w...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Swarup Patra
Kilo Guru


Sure, you can achieve this by creating a UI Policy in ServiceNow. Here are the steps:

1. Navigate to System UI > UI Policies in ServiceNow.
2. Click on New to create a new UI Policy.
3. Fill in the necessary details like Name, Table (probably 'task' in your case), Active (true), and Order.
4. In the UI Policy Actions related list, click on New.
5. Fill in the necessary details like Name, Run scripts (true), and Script.
6. In the Script, you can write a script to set the default filter. Here is a sample script:

javascript
function onLoad() {
//Set the default filter for 'Assigned to me'
var assignedToMeFilter = "active=true^assigned_to=" + gs.getUserID();
g_list.setFilter(assignedToMeFilter);

//Set the default filter for 'Assigned to my group'
var assignedToMyGroupFilter = "active=true^assignment_group=" + gs.getUser().getRecord().getValue('group');
g_list.setFilter(assignedToMyGroupFilter);
}

7. Click on Submit to save the UI Policy.

Please note that this is a basic example and you might need to adjust the script according to your exact requirements. Also, the 'group' field might not exist on the sys_user record by default, so you might need to create it or use a different field that holds the user's group.

Remember, UI Policies run on the client-side, so they do not require a form refresh to take effect. They are also not recommended for data security as they can be bypassed by savvy users. If you need to enforce these filters for data security, consider using a Business Rule or ACL instead.


nowKB.com

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Priya Singh 2 2 follow below steps

1. Go to sys_ux_list.list table and click on new and select all the respective fields. Refer below screenshot of My Cases List

SiddharamTakali_0-1706952805383.png

https://www.servicenow.com/community/developer-forum/how-to-create-default-list-filter-in-workspace/...

 

Please make my answer Correct/Helpful, if applicable

Regards,

Siddharam