I am trying to interrupt the Mark Complete save event for one of our activity entities. I had an existing script which pre Unified Interface worked perfectly, but since we switched to UI it throws an ugly error resulting in a poor user experience.
The error reads: "This form can’t be saved due to a custom setting. Error code: 0x83215605". It does however continue to work as normal after this popup (it still prevents the save and works as normal, just throws an error informing me of the save prevention).
I inserted the below Javascript on the onSave event of a new entity with no other customisations:
function preventSave(executionContext) {
e = executionContext.getEventArgs();
e.preventDefault();
console.log("Save prevented. Save mode: " + e.getSaveMode());
return;
}
From the console I can see that when I save the form normally (save mode 1) the script still executes and prevents the save, with no error. However, when I mark the record complete (save mode 58) the error message is thrown along with a console warning "Empty string passed to getElementById()" from app.js.
I've tried on multiple entities and multiple forms with the same result. Can anyone else verify that they are able to prevent the saving of activities using Mark Complete without this error occurring? As a secondary query, is there any supported way to hide the error thrown? I'd really appreciate any advice.
Dynamics version info: Server version: 9.1.0000.15631 Client version: 1.4.376-2003.3