Manage auto-save
Applies To: Dynamics CRM 2013
Auto-save helps people focus on their work without having to manage saving data in the form. Most people will appreciate not having to explicitly save data each time they update a record, but some organizations may have customizations that were designed expecting an explicit save. For these organizations there are options to manage how auto-save is applied.
In This Topic
How auto-save works
Should you disable auto-save?
Disable auto-save for the organization
Disable auto-save for a form
How auto-save works
By default all main forms for Updated entities will have auto-save enabled. After a record is created (initially saved), any changes made to a form will automatically be saved thirty seconds after the change is made. If no changes are made in the form, the automatic save won’t occur while the form is open. After a change is made the 30-second period before an auto-save begins again. The field that someone is currently editing isn’t included in an auto-save. If someone else has updated the same record while you’re editing it, those changes will be retrieved and displayed in the form when auto-save occurs.
With auto-save enabled, the save button only appears for the initial save of the record. After the record is created, the save button in the command bar isn’t shown, but you can see a button in the lower right corner that will show if there are any unsaved changes. This control is also displayed if auto-save is disabled.
You can click this button to save the record and refresh data in the form immediately. When auto-save is enabled the record will be saved whenever you navigate away from a record or close a separate window displaying a record. There is no need for the Save & Close button that appears in forms for entities that aren’t updated.
Should you disable auto-save?
If you have plug-ins, workflows, or form scripts that execute when a record is saved, they’ll run each time auto-save occurs. This might lead to undesirable behaviors if these extensions weren’t designed to work with auto-save. Whether auto-save is enabled or not, plug-ins, workflows, and form scripts should be designed to look for specific changes, and shouldn’t execute indiscriminately for each save event.
If you have auditing configured for an entity, each save is treated like a separate update. If someone lingers on a form with unsaved changes for more than thirty seconds, you’ll see an additional entry only if they add more data after the auto-save is performed. If you have reports that depend on auditing data and treat each save as an individual “touch” of a record, you might see an increase in the frequency of touches. If you are using this approach, you should consider that individual user behaviors make it an unreliable metric with or without auto-save enabled.
Disable auto-save for the organization
If you determine that auto-save will cause problems with any extensions you are using, you can disable it for your organization. There is no setting to disable auto-save for individual entities or forms.
On the nav bar, click or tap Microsoft Dynamics CRM > Settings.
Settings appears on the nav bar.
On the nav bar, click or tap Administration > System Settings.
For the Enable auto-save for all forms option, select No.
Disable auto-save for a form
If you want to disable auto-save for specific entity forms, you can add code to the OnSave event in an entity.
Note
Auto-save will be disabled for the form, but data will still be saved when people click the button in the lower-right corner. If people attempt to navigate away from a form or close a form where data has been changed they will get prompt to save their changes before they are allowed to navigate away or close the form.
On the nav bar, click or tap Microsoft Dynamics CRM > Settings.
Settings appears on the nav bar.
Click or tap Settings > Customizations.
Click or tap Customize the System.
Under Components, expand Entities and locate the entity for the form.
Expand the entity node and click or tap Forms
Open the form you want to edit.
Create a JavaScript web resource and add it to the form
In the form editor, in the Form group, click or tap Form Properties.
On the Events tab, below Form Libraries click or tap Add.
In the Look Up Record dialog box, click or tap New.
Enter the following information in the web resource form:
Name
preventAutoSave
Display Name
Prevent Auto Save
Type
Script (JScript)
Next to the Type field, click or tap Text Editor.
In the Source field, paste the following code:
function preventAutoSave(econtext) { var eventArgs = econtext.getEventArgs(); if (eventArgs.getSaveMode() == 70 || eventArgs.getSaveMode() == 2) { eventArgs.preventDefault(); } }
Click or tap OK to close the text editor.
Click or tap Save to save the web resource and then close the web resource window.
In the Look Up Record dialog the new web resource you created will be selected. Click or tap Add to close the dialog.
Configure the OnSave event
In the Form Properties window, in the Event Handlers section, set Event to OnSave.
Click Add.
In the Handler Properties window, set Library to the web resource you added in the previous step.
Type ‘preventAutoSave’ in the Function field. This is case sensitive. Do not include quotation marks.
Make sure that Enabled is checked.
Check Pass execution context as first parameter.
Important
If you do not do this the script will not work.
The Handler Properties dialog should look like this. The customization prefix: “new_” may vary based on the customization prefix set for the default publisher for your organization.
Click OK to close the Handler Properties dialog.
If there are any other event handlers for the OnSave event, use the green arrows to move this one to the top.
Click OK to close the Form Properties dialog.
Click Save and Close to close the form.
In the solution explorer, click Publish All Customizations.
After you apply this script to the OnSave event, when people edit a record using this form the message unsaved changes will appear in the bottom right corner of the form just as it would if auto-save was not disabled. But this message will not go away until people click the button next to it.
See Also
Create and design forms
Use the form editor
Design considerations for main forms
Main form presentations
Optimize form performance
Update your forms to Microsoft Dynamics CRM 2013 or Microsoft Dynamics CRM Online Fall '13
© 2016 Microsoft Corporation. All rights reserved. Copyright