I am trying to call the function below from OnSave but I keep getting:
There was an error with this field's customized event.
Field:crmForm
Event:onsave
Error:Unable to get value of the property 'getIsDirty': object is null or undefined.
and yes, I did check the box on the event to pass the context.
function form_OnSave(context) { var zipDirty = Xrm.Page.getAttribute("address_postalcode").getIsDirty(); var saveMode = context.getEventArgs().getSaveMode(); alert(saveMode); if (zipDirty == true) { context.getEventArgs().preventDefault(); //Xrm.Page.ui.controls.get("subject").setFocus(); setTimeout(function () { Xrm.Page.data.entity.save(saveMode); }, 1000); //alert("Unable to save try saving again."); } }
Why is this and do you know any way of delaying the OnSave so my REST call completes?