Skip to main content

Notifications

Disable Auto Save for Individual Forms in Model Driven Apps

Implementation Steps:

 

In my Previous Blog I have explained how to enable or disable AUTO Save functionality in Model Driven Apps. In this Blog we will see how to Prevent Auto Save in Particular or Individual forms using JavaScript.

 

Steps to Follow:

 

1. Navigate to https://make.powerapps.com

 

2. Navigate to Solution and Open the Solution which you already have else Create a New Solution

 

3. Create or Add Existing Table where you want to Prevent Auto Save functionality.

 

4. Once Table is Added, Add your Existing Web Resource. Else Create a new Web Resource.

 

5. Steps to Follow to Create a Web Resource

 

6. Add below JavaScript into your Web Resource

 

 

 

 

function preventAutoSave(executionContext) {
 var formContext = executionContext.getFormContext();
 var eventArgs = executionContext.getEventArgs();
 if (eventArgs.getSaveMode() == 70) {
 eventArgs.preventDefault();
 }
} 

 

 

 

 

7. Please find the Event Modes that will perform on SAVE operation

 

Event Mode Value
 Save 1
 Save And Close 2
 Save and New 59
 Save as Completed 58
 AutoSave 70

 

8. Now Open the Table where you want to add Web Resource --> Click Forms --> Open the Form

 

9. Once Form Opens Click Form Library and Click Add Library and Search for the Library and Select the Check Box and Click Add

 

rampprakash_0-1649167174499.png

 

10. Once Added --> Click Events at the RIGHT Side --> Select OnSave --> Click ADD EVENT HANDLER --> Input Function name as preventAutoSave --> Make Sure You Select Check Box - Pass Execution Context

 

11. Now Click Ok --> Click Save and Click Publish.

 

That's it 🙂

Comments

*This post is locked for comments

  • Dianey Profile Picture Dianey 58
    Posted at
    Disable Auto Save for Individual Forms in Model Driven Apps

    I think when I wrote that post, I was misunderstanding what the default behavior was and in the end, what I wrote is wrong.  Please disregard.

  • KelRhyne Profile Picture KelRhyne 8
    Posted at
    Disable Auto Save for Individual Forms in Model Driven Apps

    Are you sure the JavaScript is accurate?  I've added this to the OnSave Event of the form, saved/published, but it has had no effect on the Autosave functionality.

  • Dianey Profile Picture Dianey 58
    Posted at
    Disable Auto Save for Individual Forms in Model Driven Apps

    Have you noticed that this code also turns off the "Do you want to save your changes" dialog that pops up when you leave the form without pressing "Save" or "Save and Close".  It just automatically autosaves, which is very odd since what caused this is turning OFF autosave.