Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

How to access approvers only to records assigned to them for approval via query BR

Abhi33
Tera Expert

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

2 REPLIES 2

johnfeist
Mega Sage

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;
}

 

 

Basheer
Mega Sage

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;
}