The CreatorCon Call for Content is officially open! Get started here.

kim_purcell
Kilo Explorer

If you are seeing incorrect start and end dates on change requests — for example, users are able to submit or modify a request with a Planned start date later than the Planned end date without a warning message - you can implement a custom script that verifies the start and end dates before you enter the time warp:

Screen Shot 2014-10-30 at 12.22.25 PM.JPG

A date validation script for the start- and end-date fields can be set to trigger on the change request record. This script will check the start date against the current date, and display an error message if the start date is before the current date. It will also check the end date against the start date, and also display an error message if the end date is before the current date.

 

To verify these dates on a change request, one way is to create a business rule before insert or update:

  • For example: Condition = current.start_date.changes() || current.end_date.changes() || current.work_start.changes() || current.work_end.changes())
  • Use this script:

 

if (!current.end_date.nil() && !current.start_date.nil()) {
if (current.end_date.getGlideObject().getNumericValue() <=
current.start_date.getGlideObject().getNumericValue() ) {
gs.addErrorMessage('Planned start must be before Planned end');
current.start_date.setError('Planned start must be before Planned end');
current.setAbortAction(true);
}
}
if (!current.work_start.nil() && !current.work_end.nil()) {
if (current.work_end.getGlideObject().getNumericValue() <=
current.work_start.getGlideObject().getNumericValue() ) {
gs.addErrorMessage('Actual start must be before Actual end');
current.work_start.setError('Actual start must be before Actual end');
current.setAbortAction(true);

}
}

 

This message should now appear at the top of the change request if the dates are incorrect:

Screen Shot 2014-10-30 at 12.10.30 PM.JPG

 

 

For more about using scripts to verify dates, see:

Verify Start and End Dates

Change requests can be saved with a start dates later than the end date without warnings

5 Comments