How to handle Auto Save Mode in Dynamics CRM 2013

Please make your plugin and workflow design as per below suggestion for Auto Save mode in Dynamics CRM 2013:

Plug-in design

Your plug-in design should take into account a web form feature known as auto-save. In the web application entity forms, there is no Save button. The Microsoft Dynamics CRM 2013 web application automatically saves changed data in the form when needed. Depending on how you registered your plug-in, this may result in your plug-in being called very frequently for individual field changes instead of one plug-in invocation for all changes. The auto-save feature only applies to web forms for contact, opportunity, leads, account, and case entities.

It is a best practice to register your plug-in or custom workflow activities on entities and specific fields that matter most. If you can avoid it, do not register your plug-in for changes to all entity fields.

To handle “Auto Save” in JavaScript
JavaScript function getSaveMode(), returns a value indicating how the save event was initiated by the user.
For Example,
function stopAutoSave(context) {
var saveEvent = context.getEventArgs();
if (saveEvent.getSaveMode() == 70) { //Form AutoSave Event
saveEvent.preventDefault(); //Stops the Save Event
}
}
Below table describes the supported values returned to detect different entity records may be saved by the user.

Entity Event Mode Value
All Save 1
All Save & Close 2
All Save & New 59
All Auto Save 70
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
This entry was posted in MS CRM 2013. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *