powerappspowerapps-canvaspowerapps-collection

How to know if a value has been changed in a collection in PowerApps?


I have built an editable gallery which is populated and jandled by a collection - MyDataCollection. How can I check if any changes are made into the gallery, as I want to restrict the users from navigating if they haven't saved the changes.

I have already tried comparing two collections by creating a copy of the original one, but that is taking so much time (as my collection size is 15x18). Can you please suggest any better approach.

Thanks in advance.


Solution

  • An approach you can take is to add a hidden toggle control into your Gallery. Set its Default value to something like:

    Or(
      ThisItem.Status.Value <> dropDown1.Selected.Value,
      ThisItem.'Numeric Property' <> Value(txtNumericBox.Text),
      Text(ThisItem.'String Property') <> Text(txtStringBox.Text),
      If(ThisItem.'Bool Property' = true, true, false) <> checkbox1.Value
    )
    

    This toggle will toggle on for each row that has a change (and toggle off when undone). You can then count the rows that have had a change with:

    CountRows(Filter(yourGallery.AllItems, toggleModified.Value))