Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Command Designer navigation after autosave

(0) ShareShare
ReportReport
Posted on by 25

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!

  • Suggested answer
    Nya Profile Picture
    29,060 on at
    RE: Command Designer navigation after autosave

    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.

    1. Go to Settings > Administration.

    2. Choose System Settings.

    3. 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.

    1. On the nav bar, choose Microsoft Dynamics 365 > Settings.

      Settings appears on the nav bar.

    2. Go to Settings > Customizations.

    3. Choose Customize the System.

    4. Under Components, expand Entities and locate the entity for the form.

    5. Expand the entity node and choose Forms.

    6. Open the form you want to edit.

    7. Create a JavaScript web resource and add it to the form:

      1. In the form editor, in the Form group, choose Form Properties.

      2. On the Events tab, below Form Libraries choose Add.

      3. In the Look Up Record dialog box, choose New.

      4. Enter the following information in the web resource form:

        Name preventAutoSave
        Display Name Prevent Auto Save
        Type Script (JScript)
      5. Next to the Type field, choose Text Editor.

      6. In the Source field, paste the following code:

        function preventAutoSave(econtext) {  
            var eventArgs = econtext.getEventArgs();  
            if (eventArgs.getSaveMode() == 70 || eventArgs.getSaveMode() == 2) {  
                eventArgs.preventDefault();  
            }  
        }  

      7. Choose OK to close the text editor.

      8. Choose Save to save the web resource and then close the web resource window.

      9. In the Look Up Record dialog the new web resource you created will be selected. Choose Add to close the dialog.

    8. Configure the OnSave event:

      1. In the Form Properties window, in the Event Handlers section, set Event to OnSave.

      2. Click Add.

      3. In the Handler Properties window, set Library to the web resource you added in the previous step.

      4. Type ‘preventAutoSave’ in the Function field. This is case sensitive. Do not include quotation marks.

      5. Make sure that Enabled is checked.

      6. 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.

      pastedimage1641188752730v9.png

      1. Click OK to close the Handler Properties dialog.

      2. If there are any other event handlers for the OnSave event, use the green arrows to move this one to the top.

    9. Click OK to close the Form Properties dialog.

    10. Click Save and Close to close the form.

    11. 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 pastedimage1641188752731v10.png button next to it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans