- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:23 PM
Hi ram2497,
You can use a query BRule that executes before the database query is made to prevent from accessing certain records
Write BRule on ('incident') table --- When before-query
Example Script:-
This example prevents users from accessing incident records unless they have the ITIL role are listed in the caller or Opened by field . So, for ex, when self-service users open a list of incidents, they can only see the incidents they submitted.
if(!gs.hasRole("itil")&& gs.isInteractive()){
var u = gs.getUserID();
var qc = current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list","CONTAINS", u);
gs.print("query restricted to user: "+ u);}
Or You can refer the Service Now Docs as well.
Please mark it Correct or Helpful, if it works based on impact....!!!!
Warm Regards,
Priyanka
www.dxsherpa.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:11 PM
Hi,
Refer this link
https://community.servicenow.com/community?id=community_question&sys_id=febb4f96dbf657c0200f0b55ca961937
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Regards,
Abhijeet Bangera

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:12 PM
Hello Ram,
Refer the below:
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/useful_scripts/concept/c_ExScptDftBfrQryBsnRu.html
https://www.servicenowguru.com/scripting/business-rules-scripting/controlling-record-access-before-query-business-rules/
Kindly mark as Answered or Helpful, if applicable.
-Hussain K

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:13 PM
Hello,
There is one OOTB before query BR on user table. it basically checks if logged in user is admin. if not then it will add query as active is true.
It is to restrict other users than admins to see inactive users.
This can be done with ACL also. but advantage of BR is that it will not show any message like, 10 records were hided because of security reasons.
Hope this helps you.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 11:23 PM
Hi ram2497,
You can use a query BRule that executes before the database query is made to prevent from accessing certain records
Write BRule on ('incident') table --- When before-query
Example Script:-
This example prevents users from accessing incident records unless they have the ITIL role are listed in the caller or Opened by field . So, for ex, when self-service users open a list of incidents, they can only see the incidents they submitted.
if(!gs.hasRole("itil")&& gs.isInteractive()){
var u = gs.getUserID();
var qc = current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list","CONTAINS", u);
gs.print("query restricted to user: "+ u);}
Or You can refer the Service Now Docs as well.
Please mark it Correct or Helpful, if it works based on impact....!!!!
Warm Regards,
Priyanka
www.dxsherpa.com