OOTB Incident table List Pre filter block editable

Are Kaveri
Tera Contributor

Hi

 

I am working on the Incident table. In my application we use Incident table for Tracking Issues when an end user submit from portal.

We have 2 different users

ITIL

ABC-ITIL

 

this ABC is a brand on company table and incident table

when ABC user logins and check for Incident table List, 

ALL Incident- filter will be Brand = ABC

MY Open Incident - Filter will be Brand = ABC AND Active = true

 

The ABC User should not be able to edit the List filter and can apply additional filter.

I should not be able to Edit the existing pre filter.

I can able to add extra filters

 

I have written the Before Query Business rule still i as a ABC user able to edit the existing filter

I am able to click on ALL 

The filter was removed manually

Expectation - The filter should be always with Brand = ABC, if i try to edit manually it should be disabled.

AreKaveri_0-1779815665803.png

 

2 REPLIES 2

Tanushree Maiti
Tera Patron

Hi @Are Kaveri 

 

Try with this:

 

  1. Navigate to System Definition > Business Rules and click New
  2. Set the following configurations:
    • Name: Enforce ABC User Incident Filtering
    • Table: Incident
    • When: Before
    • Query: Checked
  1. Check the Advanced box. 
  2. In the Condition field, add the following script to ensure it only applies to your ABC-ITIL users:

                      gs.getUser().hasRole('abc_itil') // replace with correct role name

 

Sanple Script:

(function executeRule(current, previous /*null when async*/) {

    if (gs.hasRole('admin')) {

        return;

    }

    var queryString = "company.name=ABC";

    current.addEncodedQuery(queryString);

 

     //OR try with current.addQuery('company', 'sys_id_of_abc_company');

})(current, previous);

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

I have written query rule but still i am able to click on All manually. The filter need to be there upto brand if we click on All also it should not allow. 
this query BR didnot worked for my scenario.

 

even written read and write ACL no luck