Dynamics Tutorial: disable auto-save on only one form

save

You may have come across a problem where a customer would like to use the ‘AutoSave’ functionality but there is one particular area they want it disabled. CRM will only allow you to completely switch off AutoSave. There is a way around this.

If you want to disable it for only one entity, say the case entity you can with a little JavaScript.

Go to the form you would like it disabled on and click on form properties

Create a new web resource in the event library area

Make sure the display name and function name match

Select the type as JavaScript

In the text editor button enter the following

function preventAutoSave(econtext) {

   var eventArgs = econtext.getEventArgs();

   if (eventArgs.getSaveMode() == 70 || eventArgs.getSaveMode() == 2) {

       eventArgs.preventDefault();

   }

}

In the Event handler click add in the ‘On Save’ area

Select your script from the library

Type in your function name which is preventAutoSave (this is case sensitive)

Make sure you tick the ‘Check Pass execution context as first parameter’ (I nearly forgot to mention this bit, thank you to Mr Gray for reminding me!).

Save and publish all

Control and F5 to refresh your case screen and auto save should be disabled on this form.