Scheduled job not triggering the Event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 01:40 PM
Hi Community
I wrote a scheduled script to trigger a couple of events. 1st event will trigger 5 days before the SLO breach and the 2nd event will trigger on the breach day. Though I have the test data ready, I have tried many ways, but the events are not triggering and none of the notifications are sent out.
The SLO's are defined below
Service model | Phase Cloud | Cloud Review Purpose | SLO (# of days since Submitted) |
SaaS | Trial | 35 | |
SaaS | Pilot OR Prod | 140 | |
I/PaaS | Cloud account | 35 | |
I/PaaS | Dev OR Test | 35 | |
I/PaaS | Pilot OR Prod | 60 |
- Depending on the service model and phase, set the SLO value.
- Check if today()-Submitted date=(SLO-5), send first email
- Check if today()-Submitted date=SLO, send second email
Please review the code mentioned below and let me know where am I going wrong. Is there any API that doesnot support for the Scoped APPS ?
Thanks in advance
checkCloudReqslo();
function checkCloudReqslo() {
var SaaSTrialSlo = new GlideDateTime(gs.daysAgo(35));
var SaasPilotProdSlo = new GlideDateTime(gs.daysAgo(140));
var IPaasCloudaccountSlo = new GlideDateTime(gs.daysAgo(35));
var IPaasDevTestSlo = new GlideDateTime(gs.daysAgo(35));
var IPaasPilotProdSlo = new GlideDateTime(gs.daysAgo(60));
var slo_30 = new GlideDateTime(gs.daysAgo(30));
var gr = new GlideRecord("x_ibm_task_review");
gr.addQuery('state','=','4');
gr.query();
while (gr.next()) {
var submittedDate = new GlideDateTime(gr.u_submitted_date);
var submittedDate2 = submittedDate.getLocalDate();
var slo_30 = new GlideDateTime(gs.daysAgo(30));
var slo_135 = new GlideDateTime(gs.daysAgo(135));
var slo_55 = new GlideDateTime(gs.daysAgo(55));
if (gr.u_technology_type == 3) {
if ((gr.u_phase == 1) && (submittedDate2.getDate() == slo_30.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach5day", gr, "", "");
}
if ((gr.u_phase == 1) && (submittedDate2.getDate() == SaaSTrialSlo.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach", gr, "", "");
}
if ((gr.u_phase == 2 || gr.u_phase == 3) && (submittedDate2.getDate() == slo_135.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach5day", gr, "", "");
}
if ((gr.u_phase == 2 || gr.u_phase == 3) && (submittedDate2.getDate() == SaasPilotProdSlo.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach", gr, "", "");
}
} else if (gr.u_technology_type == 2 || gr.u_technology_type == 3) {
if ((gr.type_of_service == 12) && (submittedDate2.getDate() == slo_30.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach5day", gr, "", "");
}
if ((gr.type_of_service == 12) && (submittedDate2.getDate() == IPaasCloudaccountSlo.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach", gr, "", "");
}
if ((gr.u_phase == 8 || gr.u_phase == 9) && (submittedDate2.getDate() == slo_30.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach5day", gr, "", "");
}
if ((gr.u_phase == 8 || gr.u_phase == 9) && (submittedDate2.getDate() == IPaasDevTestSlo.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach", gr, "", "");
}
if ((gr.u_phase == 2 || gr.u_phase == 3) && (submittedDate2.getDate() == slo_55.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach5day", gr, "", "");
}
if ((gr.u_phase == 2 || gr.u_phase == 3) && (submittedDate2.getDate() == IPaasPilotProdSlo.getDate())) {
gs.eventQueue("x_usaa3_cloud_gove.notice_slo_breach", gr, "", "");
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 07:26 PM
can you share debugging have you done so far by adding logs etc?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 11:07 PM
HI Ankur
I am about to resolve the issue, but I am not able to calculate the duration between 2 date/time fields. I want to get the difference in "Number of Days". I am trying this in scoped app ut I was not able to achieve it. Do you have any idea ?
Thanks in advance