Hello!
I am playing with new command deisgner (https://docs.microsoft.com/en-us/powerapps/maker/model-driven-apps/command-designer-overview) and struggle minor problem. I have a main form of table Incidents. There is two Tabs in that form General and Tasks. In the Tasks tab i have subgrid for related records from Tasks table. So i have created custom command to Tasks subgrid for update Tasks items via Patch action and its work great but after the action system generates autosave to Incidents form and after the save form navigates to default General tab. Is there any way to prevent this default behavior and select same Tasks tab after the save?
Thanks!
Hi,
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.
Go to Settings > Administration.
Choose System Settings.
For the Enable auto-save for all forms option, select No.
If you want to disable auto-save for specific entity forms, you can add code to the OnSave
event in an entity.
On the nav bar, choose Microsoft Dynamics 365 > Settings.
Settings appears on the nav bar.
Go to Settings > Customizations.
Choose Customize the System.
Under Components, expand Entities and locate the entity for the form.
Expand the entity node and choose 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, choose Form Properties.
On the Events tab, below Form Libraries choose Add.
In the Look Up Record dialog box, choose 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, choose 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();
}
}
Choose OK to close the text editor.
Choose 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. Choose 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.
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1