Notifications

431 views

Description

In Orlando, Glide classes such as GlideDate, GlideTime, GlideDateTime and GlideSchedule, are no longer working as a conditional script in a Scheduled Report. Script functions are also no longer working, where the same conditional script works as expected in New York. We have introduced Script Sandboxing with the conditional script in Scheduled Reports, as a protection mechanism in Orlando. For further information on Script Sandboxing, please review KB0550837: Script sandboxing remediation.

Steps to Reproduce

1. Log into an Orlando instance
2. Create a new Scheduled Report:

  • Choose anything you want for the following fields: Name Report, Users, Groups, Run, Time, Subject, Introductory Message
  • Conditional = true
  • Condition (script) as follows -
// This condition should cause the scheduled report to only run on a weekday (Mon - Fri)
var today = new GlideDate();
answer = (today.getDayOfWeekUTC() < 6);


3. Save the Scheduled Report, and then click on the Execute Now button
4. Open System Log > Warnings, and observe the following message -

org.mozilla.javascript.EcmaError: "GlideDate" is not defined.
Caused by error in sysauto_report.2b13420ddbc41c1013c09207db961959.condition at line 1

==> 1: var today = new GlideDate();
2: answer = (today.getDayOfWeekUTC() < 6);


If you perform the same steps above in a New York instance, no errors are observed and the conditional script is executed as expected.

Workaround

To use date/time methods in your conditional script, for example, to send the Scheduled Report on specific days, you can use the JavaScript Date class instead of the GlideDate class. Using the JavaScript Date class, the following conditional script will send the report every weekday -

Note: The numbers for the days of the week in the JavaScript Date class are dependent on your timezone, so this will need to be confirmed on your own instance.

// This condition should cause the scheduled report to only run on a weekday (Mon - Fri)
// 0=Monday,1=Tuesday,2=Wednesday,3=Thursday,4=Friday,5=Saturday,6=Sunday
var d = new Date();
dayOfWeek = d.getDay();
if(dayOfWeek < 5) {
answer = true;
}
else {
answer = false;
}

The following conditional script will send the report on Tuesday, Wednesday and Friday, as follows -

// This condition should cause the scheduled report to only run on a Tue, Wed and Fri)
// 0=Monday,1=Tuesday,2=Wednesday,3=Thursday,4=Friday,5=Saturday,6=Sunday
var d = new Date();
dayOfWeek = d.getDay();
if(dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 5) {
answer = true;
}
else {
answer = false;
}

If the conditional script on a Scheduled Report is more complex and you need to make use of our Glide classes, then please use the following steps as a workaround -

1. Create a Scheduled Job and complete all the conditional logic of the Scheduled Report inside the Schedule Job.

2. If all the conditional logic is satisfied, you can trigger the Scheduled Report with the following script inside the Scheduled Job.

var schRpGr = new GlideRecord("sysauto_report");
schRpGr.get("<sys_id of the scheduled report>");
gs.executeNow(schRpGr);

Related Problem: PRB1396133

Seen In

Orlando Patch 1
SR - IRM - Audit Management - New York 2019 Q3
SR - IRM - GRC Profiles - Madrid 2019 Q2
SR - IRM - GRC Workbench - New York 2019 Q3
SR - IRM - PA Premium Integration - New York 2019 Q3
SR - IRM - Policy and Compliance - Madrid 2019 Q2
SR - IRM - Risk Management - New York 2019 Q3
SR - IRM - SIG Assessment Legacy - Madrid 2019 Q1
SR - IRM - SIG Questionnaire - New York 2019 Q3
SR - IRM - Vendor Risk Management - Madrid 2019 Q1
SR - ITOM - CMDB CI Class Models - 201907
SR - ITOM - CMDB CI Class Models - 201908
SR - ITOM - Discovery and Service Mapping - 201908
SR - ITOM - Discovery and Service Mapping - v1.0.35
SR - PAR - Performance Analytics Content Pack for Service Portal - v1.0
SR - Security - Integration Framework - Madrid 2019 Q2
SR - Security - Support Common - Madrid 2019 Q2
SR - Security - Support Orchestration - Madrid 2019 Q2
SR - SIR - Security Incident Response - Madrid 2019 Q2
SR - SIR - Security Incident Response Flow Designer Content - Madrid 2019 Q2
SR - SIR - Security Incident Response PA Content - New York 2019 Q3
SR - SIR - Security Incident Response UI Patch - London 2019 Q2 v.6.2.3
SR - SIR - Splunk Sighting Search Integration - Madrid 2019 Q1
SR - SIR - Store SecOps Setup Assistant - Madrid 2019 Q2
SR - SIR - Store Threat Core - Madrid 2019 Q2
SR - SIR - Store Trusted Security Circles Client - New York 2019 Q3
SR - VR - Qualys - New York 2019 Q3
SR - VR - Rapid7 - London 2019 Q2 v.6.2.1
SR - VR - Vulnerability Response - New York 2019 Q3
SR - VR - Vulnerability Response PA Content - Madrid 2019 Q2

Intended Fix Version

Quebec

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-09-25 11:49:19
Published:2020-08-27