- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 08:15 AM
Hi all,
I need to restrict "read" access for approximately 3000 account numbers(for which I have an encoded query) to users who possess the “sn_customerservice_agent” role. Obviously they need to be able to see the rest of the accounts.
Could anyone suggest the most efficient approach to achieve this? I would greatly appreciate any recommendations or example scripts. Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 01:54 AM
@Community Alums add a checkbox field DuplicateAccount on your accounts table and set the value of of this field to true for all duplicate account accounts.
In your query BR for account table you can simply use the following query.
current.addEncodedQuery('u_duplicate_account',false);
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 09:00 AM
@Community Alums You should use a query business rule in this case. In the condition field of the query business rule you can check if the user has sn_customerservice_agent role. Using current.addQuery() you can add encoded query to filter the records.
To know more about query business rule please refer to https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/company-and-domain-separation/concept/bp-before-query-business-rules.html
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 01:51 PM
Hi @Sandeep Rajput , thanks for this. Because the table is "customer_account" I cannot create a filter condition to check if user has the role.
What I need is "The 3000 account numbers records, will have to be hidden in the list view for all the users that have the sn_customerservice_agent role"
Is this achievable thruogh a query business rule you mentioned above? if yes how can I create the BR script? thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 12:19 AM
@Community Alums Yes this is achievable through query business rule. What exactly is the criteria to exclude those 3000 account? Do they belong to specific customer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 12:59 AM
@Sandeep Rajput No, they are duplicates, in fact the encoded query is pretty long as it shows all the record numbers.