Thursday, April 7, 2022

Disable Auto Save for Individual Forms in Model Driven Apps

Introduction:


In this Blog, we will see how to Disable Auto Save Functionality on Particular Form Using JavaScript.


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 ModeValue
 Save1
 Save And Close2
 Save and New59
 Save as Completed58
 AutoSave70

 

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 :slightly_smiling_face:

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...