background script works fine Schedule job script fails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 11:03 AM
I have a manual process to send the TODO notification from my custom table using UI which is in global scope and now we want it to be Automate it on the bases of Schedule job we have implemented the functionality with schedule job which runs on Global Scope. when I run background script it works properly sends the notification but at the same time schedule job fails
I have table which has service status is service in use and approval date and one checkbox under annual review so when the approval date reaches to one year completion so before 15 days I have send TODO notification
I have a todo script in script include which I call in my schedule job
Can anyone please help why schedule job is not picking up the date which has reach to 350 and send the Notification
also find the attachment of when I run from schedule job and when I run from background script
Please find the below code I have written
var gr = new GlideRecord('x_nttd7_ilk_ledger_ilk_external_service_ledger');
gr.addEncodedQuery('service_status=Service in use^infosec_department_manager_approval_dateISNOTEMPTY');
gr.query();
while (gr.next()) {
var gDate = new GlideDateTime();
gs.info(gDate);
var gdt1 = new GlideDateTime(gr.infosec_department_manager_approval_date);
var dur = GlideDateTime.subtract(gdt1, gDate); //the difference between gdt1 and gdt2
var days = dur.getDisplayValue();
days = days.split('Days');
gs.info('Testing Yearly Review Date' +dur.getDisplayValue() + ' - ' +days[0]);
if(parseFloat(days[0]) > parseFloat(350)){
gs.info('Testing Yearly Review Date passed' +dur.getDisplayValue() + ' - ' +days[0]);
// var ilkLedgerNotification= new ILK_LedgerNotification();
global.ILK_LedgerNotification.sendAnnualReviewNotification(gr);
}
}
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 11:11 AM
Hello,
Please use the appropriate forum feature: "Insert/Edit code sample" when pasting script on the forums so that it remains organized and easier to read.
As far as your issue, what do your log entries say? Please include that in your post. Most of us don't want to download attachment after attachment after attachment as we help hundreds of people on the forums and it takes up space on our end. You can easily copy and paste that right into your post, instead or just copy and paste the output (lines).
The log entries should tell you if it's executing or not.
From your post, it's not very clear if you're saying the scheduled job isn't running at all, is running but have errors, is running, but nothing is returned, etc. Unless all of that is in those two attachments (which doesn't help the wider community with your issue).
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 11:18 AM
var gr = new GlideRecord('x_nttd7_ilk_ledger_ilk_external_service_ledger');
gr.addEncodedQuery('service_status=Service in use^infosec_department_manager_approval_dateISNOTEMPTY');
gr.query();
while (gr.next()) {
var gDate = new GlideDateTime();
//gs.info(gDate);
var gdt1 = new GlideDateTime(gr.infosec_department_manager_approval_date);
var dur = GlideDateTime.subtract(gdt1, gDate); //the difference between gdt1 and gdt2
var days = dur.getDisplayValue();
days = days.split('Days');
//gs.info('Testing Yearly Review Date' +dur.getDisplayValue() + ' - ' +days[0]);
if(parseFloat(days[0]) > parseFloat(350)){
gs.info('Testing Yearly Review Date passed' +dur.getDisplayValue() + ' - ' +days[0]);
//var ilkLedgerNotification= new ILK_LedgerNotification();
global.ILK_LedgerNotification.sendAnnualReviewNotification(gr);
}
}