Hi Bipin,
Below code using & on save event calling :
/// This Function is used to restrict NRI end time less than start time
Deal_Retail.RestrictNRIEndTime = function (executionContext) {
"use strict";
try {
var isAlertDisplayed= isAlertDisplayed ? true : false;
var formContext = executionContext.getFormContext();
var lineofbusiness = common_Retail.getAttributeValue(attributes.LINE_OF_BUSINESS);
if (lineofbusiness !== null && lineofbusiness !== undefined) {
var lineOfBusinessVal = common_Retail.getAttribute(attributes.LINE_OF_BUSINESS).getValue()[0].name;
if (lineOfBusinessVal === LOB.MORTAGAGE) {
var starttime = common_Retail.getAttributeValue(attributes.CUSTOMERSTARTTIME);
var endtime = common_Retail.getAttributeValue(attributes.CUSTOMERENDTIME);
if (starttime !== null && endtime !== null) {
if (endtime <= starttime) {
if (endtime.getTime() <= starttime.getTime()) {
//common_Retail.openAlertDialog("Ok", "End Time should be greater than Start time");
var message1 = new RegExp(common_Retail.getResourceString(resx.PROSPECT_RETAIL_FORM, "AlertNRIEndTime")).toString();
common_Retail.openAlertDialog("Ok", message1.substr(1, message1.length - 2));
//common_Retail.setAttributeValue(attributes.CUSTOMERENDTIME);//nulll
var eventArgs = executionContext.getEventArgs();
eventArgs.preventDefault();
return;
}
}
}
if(!isAlertDisplayed){
if (endtime === null || endtime === undefined) {
isAlertDisplayed = true;
common_Retail.openAlertDialog("Ok", "End Time should be Entered");
var eventArgs = executionContext.getEventArgs();
eventArgs.preventDefault();
return;
}
}
}
}
} catch (e) {
common_Retail.openAlertDialog("Ok", e.message);
}
};