In Dynamics CRM Unified Interface OnSave Event Doesn't Work

7.4k views Asked by At

I have an event handler for OnSave form event following:

function saveEntityForm(executionContext) {
   executionContext.getFormContext().data.save().then();
}

when I am clicking on Save button on the form getting a pop up with following texts:

Saving in Progress

Please wait while saving is completed Error code: 0x83215603

I am using Unified Interface.

What could be the reason of happening this issue and how to resolve it?

2

There are 2 answers

0
Shahriat Hossain On

I have resolved the issue by myself adding setTimeout for my custom code instead of using explicit save method as following:

function saveEntityForm(executionContext) {
   // waiting few seconds to process the form
   setTimeout(() => {
      processForm(executionContext);
   }, 3000);
}
0
user14166282 On

The "Please wait while saving is completed" will only appear if you try to save while the form is already saving - the form does not allow two saves to happen in parallel. Thats why calling setTimeout works - it will delay calling save and by that point, the original save will be completed.

However, note that this has performance implications and, if on a slow network, may not even work since the form may not be done saving after XXX seconds!

If this code is executing in an onsave event handler, you should call preventDefault() first to stop the default save from happening, and then calling executionContext.getFormContext().data.save() will work as expected (see https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/save-event-arguments/preventdefault)

If this code is executing in an onchange handler for a particular control, you can try calling isDefaultPrevented or getSaveMode to determine whether the form is being saved and if so, calling save() https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/save-event-arguments/isdefaultprevented