On-call reminders sent on different days depending on instance date format


On-call reminders are sent when the "On-Call Reminders" scheduled job is executed. The scheduled job makes a call to the "OnCallRemindersNG" script include containing the actual code to send the reminders and perform various on-call calculations. An issue exists with the getNumberOfDaysTillNextRotation() function in this script include, where, depending on the default date format set on the instance (for example, dd-MM-yyyy, or yyyy-MM-dd), a different result is returned by this function.

The result is that reminders are sent on the wrong days. For example, a roster that changes on Monday and has a 2 day lead time (reminder should be sent on Saturday), may have the reminder sent with a 3 day lead time (on Friday). The actual day that the reminder is sent varies depending on the actual date selected, even if the dates you selected are all Mondays.

Steps to Reproduce


PART A: yyyy-MM-dd

  1. Navigate to System Properties > Basic Configuration.
  2. Ensure that the date format is set to yyyy-MM-dd.
  3. Press Save (if necessary).
  4. In the application navigator, type in cmn_rota_roster.list. 
  5. Press Enter.
  6. Open any roster from the list that has Rotation interval set to Weekly and Rotate every set to 1 Week.
  7. Set the Rotation start date field to August 11 2014 (2014-08-11).
  8. Press Update.
  9. Right-click on the form header and select Copy sys_id.
  10. Copy the sys ID that appears in the popup dialog.
  11. Navigate to System Maintenance > Scripts - Background.
  12. Run the code below, inserting the sys ID you copied from step 10 in place of the text [SYS_ID_HERE].

PART B: dd-MM-yyyy

  1. Navigate to System Properties > Basic Configuration.
  2. Ensure the date format is set to dd-MM-yyyy.
  3. Press Save.
  4. Navigate to System Maintenance > Scripts - Background.
  5. Run the same code as you ran in Part A with the same sys ID.


var roster = new GlideRecord('cmn_rota_roster');
var daysToRotation = new OnCallRemindersNG().getNumberOfDaysTillNextRotation(roster, false);

Running the script in Part A and Part B returns different results. This should not occur. Running the script in Part A and Part B should return the same result. It is the same date, so the number of days until the next rotation should be the same.


The exact date you select as the Rotation start date has an big impact on the number returned by the getNumberOfDaysTillNextRotation() function. If your reminders are being sent on the wrong day, try changing the Rotation start date field to another date that is the same weekday (for example, Monday), and then run the code supplied in the steps to reproduce with that roster's Sys ID. Keep changing the date until a date is selected where it brings back the correct Days until next rotation.

Related Problem: PRB678197