How to access approvers only to records assigned to them for approval via query BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 04:04 AM
Hi,
We have a requirement where the approver should only be able to see the incidents/change/problem only if there is an approval attached on his/her name.
How can we achieve that.
Thanks in advance,
Abhi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 07:06 AM
HI Abhi,
You can accomplish this with ACLs or Before Query BRs. You should already have OOTB Before Query BRs for those tables. In either case it becomes a matter of adding a lookup to sysapproval_approver to check if there is an approval record for that object assigned to the user. Here's an example for putting it in a script in an ACL
var theUser = gs.getUserID();
var theApprovers = new GlideRecord("sysapproval_approver");
the Approvers.addQuery("approver", theUser);
theApprovers.addQuery("sysapproval", current.sys_id);
theApprovers.query();
if (theApprovers.next()) {
answer = true;
}
else {
answer false;
}
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 07:20 AM - edited 01-26-2023 07:21 AM
Hi @Abhi33 ,
You can achieve this through either of ACL or Query Business Rules
In the script part of ACL or Query BR write as below and test the functionality.
var approver = new GlideRecord("sysapproval_approver");
approver.addQuery("approver", gs.getUserID());
approver.addQuery("document_id", current.getUniqueValue());
approver.query();
if(approver.next())
{
answer = true;
}
else
{
answer false;
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.