Hi,
I am getting this error 'TypeError: Cannot read property 'preventDefault' of undefined'.
Requirement is user should not be able to save the form when a field condition is not satisfied.
Code:
var AccountCustomJS = {
telephoneValue: function(executionContext){
debugger;
var formContext = executionContext.getFormContext();
var telephoneVal = formContext.getAttribute("telephone1").getValue();
if(telephoneVal.length != 10){
var alertStrings = { confirmButtonLabel: "Ok", text: "Make sure your phone number is 10 digits", title: "Error" };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);
executioncontext.getEventArgs().preventDefault();
}
else
var alertStrings = { confirmButtonLabel: "Ok", text: "Phone Number Saved", title: "Success" };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);
}
}
Thanks in advance.