In 2017, Natraj Yegnaraman shared a clever method to cancel the save of a form. His approach was to cancel the save before the asynchronous operation and then retrigger the save if needed after the asynchronous operation is resolved. You can find all the details on the following link.
This approach is explained by the fact that the save handler was always synchronous. Now in 2021, Microsoft has given the possibility to switch the save handler from synchronous mode to asynchronous mode. The process to enable the asynchronous mode for the save handler is explained in Microsoft Docs.
Below, I am sharing an example to cancel the save using the new method preventDefaultOnError() proposed by the client api. Please note, you must first activate the asynchronous mode on your MDA before starting.
The save is blocked and the following error is displayed
In this case, the save is canceled, and no error is displayed.