Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Unable to get property 'then' of undefined or null reference

$
0
0

Hello everyone,

I have an error happens at Xrm.Page.data.save(saveOptions).then(successCallback, errorCallback) function.

My situation is like following: 

  • I have a plugin that checks for some business rule at (Service Appointment) form.
  • Business Rule is to prevent any user of creating new (Service Appointment) if he is already have another (Scheduled) one.
  • I created the plugin as (PreCreate) to run before save new (Service Appointment)
  • Plugin working normally, and throw (InvalidPluginExecutionException) when business rule is violated
  • Now I wrote a JavaScript to handle (InvalidPluginExecutionException) to show error message as a Form notification using ( Xrm.Page.ui.setFormNotification)
  • I attached that new JavaScript to (Service Appointment) Form to be fired (OnSave) event.
  • Following code clarify the JavaScript code
function StartSave() {
    //========================================================
    //Clear old notifications
    Xrm.Page.ui.clearFormNotification();

    //Save Form data
    Xrm.Page.data.save().then(SuccessCallback, ErrorCallback);
}
  • Now error happens at (Xrm.Page.data.save().then). Error is (Unable to get property 'then' of undefined or null reference).

I don't know why this error happens and how to know its root cause. Is OnSave event is not correct?? 

I used following links samples to mimic its behavior:

I use CRM 2015 on Premise.

Thanks in advance.

Kind Regards,


Wa'el Mohsen


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>