Default filter for task_sla table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 12:36 PM
Hi family!
I wanted to exclude 'Cancelled' SLAs from list view of task_sla table and this should be applied for all users and even in INC related list.
We can't set filter in the module as task_sla is not a module.
Need your help here!
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 05:59 PM
@JuileeD Can you please explain more where you want to apply this filter ? is it in related list ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 06:13 PM
I have 2 solutions for you:-
Solution 1: Create a Business Rule to Filter Out "Cancelled" SLAs
Navigate to Business Rules:
In ServiceNow, go to System Definition > Business Rules.
2. Create a New Business Rule:
Click on New to create a new business rule.
3.Define the Business Rule:
Name: Give it a descriptive name like Exclude Cancelled SLAs from List View.
Table: Set the table to task_sla.
Advanced: Check the "Advanced" option to allow scripting.
4. Condition:
Leave the condition field empty (as we want this to apply globally).
5. Script (in the advanced section): Add the following script to filter out "Cancelled" SLAs:
(function executeRule(current, previous /*null when async*/) {
if (current.stage == 'cancelled') {
// Prevent the record from being shown in list views
current.setAbortAction(true);
}
})(current, previous);
6. When to run:
Set the "When" field to Before to run this rule before the query happens.
Save and Activate:
7. Save the business rule and make sure it’s active.
Solution 2: Use an ACL Rule to Restrict "Cancelled" Records
You can use an Access Control (ACL) to filter out "Cancelled" records, though this is a more restrictive solution.
1. Navigate to Access Controls:
Go to System Security > Access Control (ACL).
2. Create a New ACL:
Table: Select task_sla.
Operation: Select read (since you want to prevent users from reading the cancelled SLAs).
Name: Set it to something like Restrict Cancelled SLAs.
3. Condition: Add a condition to block access to records where the stage is Cancelled.
4. Script (if needed): You could add a script to ensure that this applies to the correct records:
answer = current.stage != 'cancelled';
Save and Activate:
Save the ACL and ensure it’s active.