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 Platform Community / Forums / Power Apps / Detect if any changes ...
Power Apps
Answered

Detect if any changes were made

(0) ShareShare
ReportReport
Posted on by 905

Hello,

 

I have a formula:

If(IsBlank(DataCardValue11.Text);Notify("Musisz wskazać nazwę propozycji.";NotificationType.Error);
If(IsBlank(DataCardValue18.Selected.Value);Notify("Musisz wybrać przynajmniej jedną nazwę kategorii.";NotificationType.Error);
If("Zmiana Legislacyjna" in DataCardValue18.SelectedItems.Value && IsBlank(DataCardValue22.Text);
Notify("W przypadku wybrania pola kategoria 'Zmiana legislacyjna' należy uzupełnić dodatkowe pole dotyczące zmiany przepisu.";
NotificationType.Error);
If(Len(DataCardValue19.Text) < 79;Notify("W polu opis zmiany należy wprowadzić minimum 80 znaków.";NotificationType.Error);
If(IsBlank(DataCardValue9.Selected.Value);Notify("Musisz wskazać zasięg zmiany.";NotificationType.Error);
UpdateContext({variableDefault:" "});UpdateContext({showDialog:true;variableDefault:""}))))))

 

This formula is placed on button - it has a lot of verification, and then if all is correct it set showDialog to true - this shows popup do you really want to save?

 

My problem is that this popup will be shown even if no changes were made. And saving means a lot in my app (It delete a lot of data - reset likes etecera).

 

Is it possible to detect if changes were made? Or even set button inactive if there are no changes?

 

I will be grateful for your help 😉

Thank you.

Categories:
I have the same question (0)
  • Vijay Tailor Profile Picture
    2,961 on at

    Hi ,

    If you are using Form then you can use FormUnsaved Properties to detect a change in the Form.

    For More details find the below screenshot. for reference.

    VijayTailor_0-1600777291878.png

     

  • Elitezone Profile Picture
    905 on at

    I added it to DisplayMode of button, but it does not work:

     

    If((Form4.Mode=FormMode.View || !Form4.Unsaved); DisplayMode.Disabled;DisplayMode.Edit)

    First part works tho - if Form4 is in View then button is inactive. Why this doesn't work? 

  • Vijay Tailor Profile Picture
    2,961 on at

    Use Like that.

    If(!Form4.Unsaved || Form4.Mode=FormMode.View, DisplayMode.Disabled;DisplayMode.Edit)

  • Elitezone Profile Picture
    905 on at

    Doesn't work - when I open a Form in ViewMode it blocks the button - in Edit mode without any changes - it does not block button.

  • Elitezone Profile Picture
    905 on at

    Any other ideas guys?

    Can this button be blocked?

     

    Can changes be detected somehow?

  • v-jefferni Profile Picture
    on at

    Hi @Elitezone ,

     

    Do you want to set the Submit Button to Disable when form items has not been changed?

     

    If so, I suggest to set variables in OnChange properties of each CardValue. Sample like below:

     

    Set(varChange1,If(DataCardValue1.Text=Parent.Default,0,1)) on the OnChange of DataCardValue1
    Set(varChange2,If(DataCardValue2.Text=Parent.Default,0,1)) on the OnChange of DataCardValue2
    Set(varChange3,If(DataCardValue3.Text=Parent.Default,0,1)) on the OnChange of DataCardValue3
    Set(varChange4,If(DataCardValue4.Selected.FieldName=Parent.FieldName,0,1)) on the OnChange of DataCardValue4
    Etc…

     

    On the DisplayMode of Submit Button:

     

    If(varChange1=1||varChange2=1||varChange3=1||varChange4=1||varChange5=1, DisplayMode.Edit,DisplayMode.Disabled)

     

    32.jpg

    On the OnVisible property of the Edit Screen:

    33.jpg

     

    Set(varChange1,0);Set(varChange2,0);Set(varChange3,0);Set(varChange4,0);Set(varChange5,0)

     

    This ensures the Button be disabled by default.

     

    In addition, you could as well set the Tooltip of Submit Button with:

     

    If(varChange1=1||varChange2=1||varChange3=1||varChange4=1||varChange5=1,"","Nothing changed")

     

    When Button is disabled, hint text is ”Nothing changed” for users to know why.

     

    By the way, Form.UnSaved could be used to disable selecting from the gallery while current form has not been saved/submitted.

     

    Best regards,
    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution  to help the other members find it.
  • Elitezone Profile Picture
    905 on at

    @v-jefferni 

    Thank you.

    But what about field with Selected Values.

    I tried this:

     

     

    Set(varChange2;If(DataCardValue18.Selected.Value=Parent.Default;0;1))

     

     But it shows invalid type of argument.

     

    I also have in this datacards attachment list.

    Is it possible to verify whether this list was updated?

     

    In addition - I have a problem with Edit screen function:

    Elitezone_0-1600849547374.png

    Unexepected Signs. Signes are used in an unexepected way.

    I only user varChange 1,3,4 why is this error happening?

     

     

     

  • v-jefferni Profile Picture
    on at

    Hi @Elitezone ,

     

    For your first question, is the control a Dropdown Box?

    If it is a dropdown, you may try to replace the Parent.Default with Gallery.Selected.FieldName.Value.

     

    For the second question, I believe there is no direct way to verify whether the list was updated. As a workaround, you may use a Label to show when the list modified as a reminder. And in my mind, when submit successfully, apps are usually set to navigate to another screen.

     

    For the last question, please use ";;" to replace the semicolon at the end of lines.

     

    Best regards,
    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution  to help the other members find it.

     

  • Elitezone Profile Picture
    905 on at

    @v-jefferni 

    I am having a bit of troubles.

     

    1.

    Set(varChange1;If(DataCardValue11.Text=Parent.Default;0;1))

    This is my Name - DataCardValue11 onChange property.

     

    2. 

    If(Form4.Mode=FormMode.View || varChange1=0; DisplayMode.Disabled;DisplayMode.Edit)

    This is my button DisplayMode property

     

    3. 

    This is my Screen7 (the screen on which form is placed)

     

    Set(varChange1;0)

     

    Button is always Blank. No matter what I write in the DataCardValue11

    Something is wrong with my implementation? It seems like varChange is not changing to 1? Why is button always grey and not clickable?

     

     

    Regarding this: 

    If(varChange1=1||varChange2=1||varChange3=1||varChange4=1||varChange5=1,"","Nothing changed")

     How can I make this conditionally to show Nothing changed when varChange=1 but show "Saved" when varChange=0?

     

    Thank you!

  • v-jefferni Profile Picture
    on at

    Hi @Elitezone ,

     

    There is a logical problem in you formula.

    You are in the Form of Edit Mode, so the If statement always returns the false result "DisplayMode.Edit".

    Modify the formula to:

     

    If(Form4.Mode=FormMode.Edit && varChange1=1; DisplayMode.Edit;DisplayMode.Disabled)

     

    For the second question, if varChange equals 1, then it means value has been changed, why the hint would be "Nothing Changed"?

    I suppose that you want to make the button's hint be "Saved" when user has no operation on any controls?

     

    If so, I suggest you set another variable on the OnChange properties:

     

    Set(varOperate1,1)
    Set(varOperate2,1) 
    etc. 

     

    And OnVisible of the screen:

     

    Set(varOperate1,0);Set(varOperate2,0)

     

    The button's Tootip should be:

     

    If(varOperate1=0&&varOperate2=0,"Saved",varChange1=0&&varChange2=0&&(varOperate1=1||varOperate2=1),"Nothing changed","")

     

     

    Best regards,
    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find 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

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard