CRM 2011 – Quick tip – Javascript to stop a form saving

Posted on December 2, 2011

8


This is probably something you will need to do at some point.  You want to validate a page and if it doesn’t fit certain criteria then the form should not be saved until the user has met your criteria.

To stop the save event in Javascript all you need is this

event.returnValue = false;

Tanguy the CRM tool guy (and CRM MVP) put something very interesting in the comments but I thought I would promote it to this very small blog post

The new method in CRM 2011 is the following one:

Xrm.Page.context.getEventArgs().preventDefault();

preventDefault : Cancels the save operation, but all remaining handlers for the event will still be executed.

About these ads