Condition to Check for Item's Category on Approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 06:00 AM
Hi All,
I have a scheduled job that runs daily to issue approval reminders for outstanding requested item approvals. I now want to split this job to issue one email notification for item's under Hardware category and other for all others.
The issue is that I can't seem to add a correct query to find outstanding approval for requested items where item's category is Hardware.
Queries that I tried and they did not work:
- appr.addQuery('sysapproval.ref_sc_req_item.cat_item.category.sys_id', 'e29b2cba0f594200a17bdd44e2050ef6');
- appr.addQuery('sysapproval.ref_sc_req_item.cat_item.category', 'e29b2cba0f594200a17bdd44e2050ef6');
- appr.addQuery('sysapproval.ref_sc_req_item.cat_item.category', 'Hardware');
Does anyone have any thoughts on what I'm missing here?
Thank you!!
Kamile

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 09:32 AM
If you notice, I have not used the category while querying and using it inside while loop.
It works I know that, as it is active on my instance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 09:04 AM
FYI - this is a script that I use for reminders. The line in bold is the one I am having trouble to make this job work. If I exclude it, the job works perfectly for all RITM approvals.
remindApprovers();
function remindApprovers(){
// remind everyone, all the time?
var spamMachine = false;
var appr = new GlideRecord('sysapproval_approver');
if (spamMachine){
appr.addQuery('state', 'requested');
appr.addQuery('sysapproval.sys_class_name', 'sc_req_item');
}
else {
appr.addQuery('state', 'requested');
appr.addQuery('sysapproval.sys_class_name', 'sc_req_item');
appr.addQuery('sysapproval.cat_item.category', 'e29b2cba0f594200a17bdd44e2050ef6');
appr.addQuery('sys_created_on', '>', gs.daysAgoStart(20));
appr.addQuery('sys_created_on', '<', gs.daysAgoEnd(20));
}
appr.query();
while (appr.next()){
gs.eventQueue("requestitem.itil.approve.reminderfnl.HSC", appr, gs.getUserID(), gs.getUserName());
gs.log('Re-requested final approval of task ' + appr.sysapproval.number + " by " + appr.approver.name);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 04:08 AM
So I just ran some tests and actually the script I posted below is working just fine and using different notifications for a different category items. So no changes needed at all
Thank you everyone for help!