Notifications

1584 views

Description

When creating or modifying a change request, users can set start dates later than end dates.
This is reproducible on any OOB instance across all releases including Dublin.

Steps to Reproduce

Workaround

A date validation script for the fields [start_date], [end_date], [work_start], [work_end] can be set to trigger on a Change Request [change_request] record as described below.

Create a Business Rule before insert or update

Condition:

current.start_date.changes() || current.end_date.changes() || current.work_start.changes() || current.work_end.changes()

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);
	}
}

Create a Client Script onChange

Example: 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue == '')
		return;

	var end = g_form.getValue("end_date");
	var start = g_form.getValue("start_date");
	// Skip if start or end is blank
	if (start == "" || end == "")
		return;

	// Get user's date time display format
	var format = g_user_date_time_format;
	var isEndBeforeStart = compareDates(start, format, end, format);
	// 1 (true) if start is greater than end
	// 0 if end is greater than start of if they are the same
	// -1 if either of the dates is in an invalid format
	if (isEndBeforeStart)
		alert("End must be after start");
}

Related Problem: PRB596822

Seen In

Calgary Patch 2 Hot Fix 5

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-09-20 10:45:13
Published:2014-10-17