- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 07:47 AM
I have a Query business rule (on sc_req_item table) that restricts visibility of RITM records. I want to add a condition to that business rule to allow the users to view the RITM records that they are approvers of. The sc_req_item field does not have a Approver(s) field that I can use in the query condition. Also, approval records are stored in a different table, sysapproval_approver. How to check if the current logged in user is an approver of the current RITM and then grant permission. We already have an ACL that grants approvers the read access, but the Query business rule is restricting access, so I want to add some logic inside the Query business rule only.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 11:57 AM
This script in a before Query Business Rule on the sc_req_item table will cause only those RITMs where the current user is an approver to appear in the list:
(function executeRule(current, previous /*null when async*/) {
var answerArr = [];
var app = new GlideRecord('sysapproval_approver');
app.addQuery('approver', gs.getUserID());
app.query();
while (app.next()){
answerArr.push(app.sysapproval.toString());
}
current.addQuery('sys_id', 'IN', answerArr.join(','));
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 11:57 AM
This script in a before Query Business Rule on the sc_req_item table will cause only those RITMs where the current user is an approver to appear in the list:
(function executeRule(current, previous /*null when async*/) {
var answerArr = [];
var app = new GlideRecord('sysapproval_approver');
app.addQuery('approver', gs.getUserID());
app.query();
while (app.next()){
answerArr.push(app.sysapproval.toString());
}
current.addQuery('sys_id', 'IN', answerArr.join(','));
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 12:15 PM
Thanks for your response, Brad. It was helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 05:01 PM
You are welcome.