Notifications
Announcements
No record found.
Good Morning,
Does anyone know what is the new javascript to prevent saving the form and to close the form for CRM that is above version 9.0?
Thank you
Hey Ricardo,
The new Dynamics 365 Client API has a method to prevent the form from saving, as shown below:
function PreventSave(executionContext) { var saveMode = executionContext.getEventArgs().getSaveMode(); if (saveMode == 1 || saveMode == 2 || saveMode == 70) { //Save, Save and Close, or Auto Save //Prevent the save executionContext.getEventArgs().preventDefault(); } }
As for closing the form, I'm not sure what you mean. If you wanted to redirect away from the form to elsewhere in the system you could use:
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto
Depending on whether or not you are using the Unified Interface, the above snippets/links may or may not be relevant.
Thanks.
Matt Bayes
Hi,
Thank you for your help.
The code is right is preventing the form from being saved, but now I need Javascript to close the form.
Would you know what this code is?
Tanks
Hello,
I believe formContext.ui.close() is what you're looking for - docs.microsoft.com/.../close
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 108 Super User 2025 Season 2
Jimmy Passeti 50 Most Valuable Professional
Gerardo RenterÃa Ga... 49 Most Valuable Professional