Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to convert the scheduled script execution from days to minutes

Community Alums
Not applicable

Hi All, 

For getting the ritm count which are waiting for approval and in active state we have a schedule script like as below. 

 

function getSAPReq() {
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery("active=True^cat_item.name=SAP Request^state=1");
gr.orderByDesc('sys_created_on');
gr.query();
var sap_req_sys_ids = [];
while (gr.next()) {
sap_req_sys_ids.push(gr.getValue('sys_id'));
}
return sap_req_sys_ids;
}

var ids = getSAPReq();
//gs.info(ids.length);
sendPendingApprovalReminders(ids);

function sendPendingApprovalReminders(targetIds) {
if (targetIds.length == 0) { return; }
//var sysids = [];
var grSA = new GlideRecord('sysapproval_approver');
grSA.addEncodedQuery("source_table=sc_req_item^sys_created_onRELATIVELT@dayofweek@ago@1^state=requested^sys_created_onRELATIVEGT@dayofweek@ago@500");
grSA.addQuery('sysapproval', 'IN', targetIds);
grSA.query();
//gs.info(grSA.getRowCount());
while (grSA.next()) {
var gdt = new GlideDateTime();
var sec = gs.dateDiff(grSA.sys_created_on.getDisplayValue(), gdt, true);
var days = Math.floor(sec / (60 * 60 * 24));
//gs.info(days);
if (days && days > 0) {
//sysids.push(grSA.getValue('document_id'));
gs.eventQueue('sapreq.pending.app.reminder', grSA, days-1);
}
}
//gs.info(sysids)
}

 

 

but currently its configured in days. Need to convert the same into minutes. 

Need suggestions. 

0 REPLIES 0