Condition to Check for Item's Category on Approval

Sofija
Giga Expert

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:

  1. appr.addQuery('sysapproval.ref_sc_req_item.cat_item.category.sys_id', 'e29b2cba0f594200a17bdd44e2050ef6');
  2. appr.addQuery('sysapproval.ref_sc_req_item.cat_item.category', 'e29b2cba0f594200a17bdd44e2050ef6');
  3. 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

12 REPLIES 12

Surprisingly when i run below code in background - script, it gives me sys_id of RITM... and not GlideObject which will enable me to further dot walk. Trying to find out why is this so. Will update you.



var grr = new GlideRecord('sysapproval_approver');


grr.addQuery('sysapproval', 'sys_id_of_ritm');


grr.query();


while(grr.next()){


gs.print(grr.sysapproval);


}


Ok, please let em know if you figure this out. Below I posted the script I am trying to update if that helps..


This is not possible Kamile. The sysapproval field is a reference to task table, and we are trying to get the category information which is on sc_req_item table. We cannot access child table specific columns being on task table. You probably need to modify your script heavily.



Thinking about how we can achieve this.


Kalaiarasan Pus
Giga Sage

I don't have a definite answer for your question as it has baffled me in the past (Even we have such a scheduled job triggering reminders and we are on Eureka currently).



This condition would work inside the script



var gr = new GlideRecord('sysapproval_approver');


gr.addQuery('sysapproval.sys_class_name', 'sc_req_item');


gr.addQuery('state','requested');


gr.query();


while(gr.next())


{


if(gr.sysapproval.cat_item.category=='d258b953c611227a0146101fb1be7c31')   //replace the catalog sys id


{


gs.print(gr.sysapproval.cat_item.name);


}


}


I already tried with sys id (it's in the list of the ones that didn't work). Below I posted the script I am trying to modify if that would help to see what I am trying to do?