简体   繁体   中英

In Dynamics CRM Unified Interface OnSave Event Doesn't Work

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?

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);
}

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://docs.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://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/save-event-arguments/isdefaultprevented

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM