web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Form Unsaved

(0) ShareShare
ReportReport
Posted on by 202

Hello, 

1. I'm having a form(sql connection) where i'm using the same form for both new record & edit record

2. on visible of screen i was doing 
    

If(
 IsBlank(vFormPD.ID), //where vFormPD is record
 NewForm(Form_PD),
 EditForm(Form_PD)
);

 

3. Now the actual problem is on displaymode of submitform button. I'm having a submit button. on displaymode of button

If(Form_PD.Unsaved,DisplayMode.Disabled,Edit)

 

I've observed this form.unsaved is only working once but when I create a new record again the button is getting enabled by default !

 

How to make it disable untill the form got saved

Categories:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Sharuk 

    • button display mode should be
    • If(EditForm1.Unsaved,DisplayMode.Edit, DisplayMode.Disabled)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Sharuk 

     

    And also you can use button fill property to

    If(EditForm1.Unsaved,RGBA(100, 10, 10, 1), RGBA(0, 0, 0, 0))

     

    This helps visually

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Sharuk 

    First, you might want to simplify your design by using only one form.  The form can be in New, Edit or View mode...so only one is needed.

     

    Next, I believe your logic is a little backward on the conditional statement - you want your button to be in Edit mode if the form is Unsaved, not in disabled.  So your formula should be:

       If(Form_PD.Unsaved && Form_PD.Valid, Edit, Disabled)

    Note: I added the .Valid check in there too...it's good practice to check that the form is valid before submitting as well.

     

    Now...the Unsaved property confuses many.  It's quite simple.  Unsaved goes to true whenever any datacard in your form has a different Update value result than the Default value result.  So, if you have changed any formulas in your Default or Update properties of any datacards, or if you have changed any of the formulas of any controls in the datacards that supply their values to the Update property, then this is a good place to start.

     

    Another handy method that I use often is to set the Fill property of each data card to : If(Self.Default <> Self.Update, Red, White)

    This formula will set the fill of the datacard to red if there is a difference between the two primary properties needed for UnSaved to work.

    Note: the above will work fine for simply field types (text, number, date, etc.) It needs modification on complex columns, example, a choice column with a dropdown in its data card would have a datacard fill property of : If(ThisItem.yourChoiceColumn.Value <> dropdownName.Selected.Value, Red, White)

     

    So, if you are getting an Unsaved property of true on a new form or unedited record, then this is where to start looking.

     

    I hope this is helpful for you.

  • Sharuk Profile Picture
    202 on at

    Hi @RandyHayes / @StalinPonnusamy 

    thanks for all the info.  sorry I've miscommunicated it. 


    I'll be having 2 buttons in mycase 

    a) Save : this is where i'm submitting the actual form ==> on select ==> submitform()

    b) Submit : this shouldn't be enable until save is clicked and form is saved  ==>and on displaymode ==> 

    If(Form_PD.Unsaved,DisplayMode.Disabled,Edit)

     

    @RandyHayes  to your question:
    if you are getting an Unsaved property of true on a new form or unedited record, then this is where to start looking.

     

    for the first time when a save new record it is working perfect. when I'm trying to create 2nd record form.unsaved is giving false which by default making my submit button to enable.


  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Sharuk 

    But your logic is backward.  You are stating in the formula that if the form is Unsaved (meaning it has changes) then you want the submit button to be Disabled....how would the user save their changes?

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    HI @Sharuk 

     

    Is this not working for you?

    If(EditForm1.Unsaved && EditForm1.Valid,DisplayMode.Edit, DisplayMode.Disabled)

     

  • Sharuk Profile Picture
    202 on at

    @RandyHayes 

     

    1. first user will click on save button which will save the form submitform(Form_PD)

    2. once the form is submitted successfully then 2nd button will be enabled (where display mode is if(form.unsaved,disable,enable) )

    3. then after submitting the form successfully , the 2nd button will be enabled and on click of 2nd button i'm calling some flow

    Sharuk_0-1629214958543.png

     

    once i click the save button, the form has to be saved then run flow should be enable

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Sharuk 

    Ah see...your picture is a little clearer.  You first mentioned that you had a Save button and a Submit button - those would be one and the same from a PowerApps perspective as saving is submitting.

     

    SO, your Save button should have the formula I provided on the DisplayMode property:

       If(Form_PD.Unsaved && Form_PD.Valid, Edit, Disabled)

     

    Your Run Flow button should have the following on the DisplayMode:

       If(Form_PD.Unsaved, Disabled, Edit)

     

    Now that we have that clear, we are back to my original suggestion to determine what is causing your form to think it is unsaved.  Have you looked over any customizations to the form that you have made? 

    Also, what is your Item property of the form and what is your OnSuccess action formula?

  • Sharuk Profile Picture
    202 on at

    @RandyHayes 
    Yes, this should be things

     

    Save button:

       If(Form_PD.Unsaved && Form_PD.Valid, Edit, Disabled)

    Run Flow button:

       If(Form_PD.Unsaved, Disabled, Edit)

     

    Now coming to my issue,

    1. yes i've unlocked all the datacards for customizations 

    2. items property : If(!IsBlank(vFormPD.ID),vFormPD)

    3. form onsuccess: Set(vFormPD,Self.LastSubmit);EditForm(Form_ID);
    4. screen onvisible: 

    Set(
    vFormPD,
    LookUp(
    Details,
    ID = gallery.selected.id
    )
    );
    If(
    IsBlank(vFormPD.ID),
    NewForm(Form_PD),
    EditForm(Form_PD)
    );
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Sharuk 

    Let's make some changes to start with to streamline a bit.

    1. Get rid of the OnVisible formula.

    2. Change your Gallery OnSelect (or the OnSelect of a button/control that you might be using to edit the record) to:

    Set(vFormPD, LookUp(Details, ID = ThisItem.ID));
    Navigate(yourFormScreen)

    3. Change the Item property of FormPD to :   vFormPD

    4. Change the DefaultMode of your form to: Edit

    5. If you have some button to create new records, then change the formula on that to:

    Set(vFormPD, Defaults(Details);
    Navigate(yourFormScreen)

    6. Change your OnSuccess to just :  Set(vFormPD, Self.LastSubmit);

     

    Now...that cleans up the set up of the form and its record.  So, if there are Unsaved property issues still, then we need to dig into the datacards to find out what formulas you might have in there that are interfering with the Default to Update property equality.

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

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard