unable to read all records due to a Query BR

sakshi18
Tera Contributor

Greetings,

As part of our requirement, we have a table (Table A) with 4 personas (i.e., admin, planner, viewer, manager). 

1. Admin - the user should be able to view all the records in the table, even if the the user is an planner, viewer or manager.

2. planner/ viewer/ manager - the user should see the filtered list of records as per their involvement (i.e.., the user should be either planner, viewer, or manager).

We have written a query BR where we were sending a query as per user role to fetch the filtered list on Table A list view. (working)

 

We also have a catalog field with values from another table (Table B) and we need to exclude values/records that has been already submitted in the previous mentioned table (Table A).

We are supposed to fetch all record names (using Script Include) but when we are trying, we are unable to fetch all the data. The data we are receiving is also filtered due to the Query BR and the Script include is unable to access the other part of the data which was previously filtered.

 

Please help us to fulfill this requirement in such a way that we get filtered list as per user, also we should be able to fetch all the record names with no reference to the role of the user.

 

Thanks in advance,

Sakshi.

 

 

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@sakshi18 

2 things to do

1) Do this in your query BR on table A.

Add condition of interactive session check

AnkurBawiskar_0-1730899980164.png

 

2) when you query Table A via Script include ensure you use setWorkflow(false) while performing GlideRecord so that it excludes the Query BR

something like this

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

        // Add your code here
        var gr = new GlideRecord("table A");
        gr.addQuery("name", "value");
        gr.setWorkflow(false);
        gr.query();
        if (gr.next()) {
           
        }
       

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader