function ValidateMaintenanceEndDate(executionContext)
{
var formContext = executionContext.getFormContext();
var startDateField = formContext.getAttribute("new_maintenancestart");
var endDateField = formContext.getAttribute("new_maintenanceend");
var endDateFieldControl = formContext.getControl("new_maintenanceend");
var startDate = startDateField.getValue();
var endDate = endDateField.getValue();
if (startDate != null && endDate != null)
{
startDate = new Date(startDate.toISOString().substr(0, 10));
endDate = new Date(endDate.toISOString().substr(0, 10));
endDateFieldControl.clearNotification("ErrEndDate");
if (startDate >= endDate)
{
endDateFieldControl.setNotification("cannot be before or equal to Maintenance Start.", "ErrEndDate");
}
else
{
endDateFieldControl.clearNotification("ErrEndDate");
}
}
}
More Reference
How to format Date and Time with AM / PM
Guidelines
to write good JavaScript code in Microsoft Dynamic CRM
Refreshing
Rollup field using JavaScript
Most
common JavaScript methods for Dynamic 365 CRM
No comments:
Post a Comment