web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Drew Poggemann Profile Picture
    4 on at

    Hi Wael,

    According to the following article:  https://msdn.microsoft.com/en-us/library/dn481607.aspx it looks like the save will only work for specific "updated entities" as identified here:  https://msdn.microsoft.com/en-us/library/gg328261.aspx#BKMK_UpdatedEntties

    It does not look like service appointment is in this list so maybe this is why it is not working?

    Hope this helps!


    Thanks,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans