Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Data wiping when I save if I don't make any changes

(1) ShareShare
ReportReport
Posted on by 8
Hello,
 
I am newer to power apps so not sure if I am posting in the correct location, but I am having an issue where I have multi-selection checkboxes that is set up inside of a gallery linked to share-point list. This list is a column that has 5 choice options that has multiple selections enabled. I have it saving properly by using Collect(variable, ThisItem) on the OnCheck section and Remove(variable, ThisItem) on the OnUncheck section which is working. Also, in the default I have 
ThisItem in datacard.Default which is also working. It saves correctly but when I reopen the form and hit save it wipes the data that was saved. I know this is due to the fact the variable is blank on load. 
I just can't seem to find the way to get it to save/get the values that were previously saved and apply it to either the variable or some other thing. I have tried to do some functions in the OnStart but they didn't work.
I have also tried to assigning the variable on start as well but doesn't seem to get the value from the previously selected values to assign it to that variable. 

I appreciate the help ahead of time.
Categories:
  • Peter6803 Profile Picture
    8 on at
    Data wiping when I save if I don't make any changes
    Hello thank you for the responses,
     
    I tried the Clear Collect, and it didn't work for me.
     
    @FLMike I'll start over and hopefully explain things better.
     
    So, I have a SharePoint list that has a column that is type Choice with 5 options. It also has the ability for multiple selections. 
     
    Now when I got into power apps to customize, I have that column's DataCard that has a Gallery inside of it that shows the choices from that column inside of it. It also has a checkbox inside of the gallery that automatically shows all 5 options inside of the gallery. the properties for the checkbox are below:

    OnCheck: Collect(SelectedItems, ThisItem)
    OnUncheck: Remove(SelectedItems, ThisItem)
    Default: ThisItem in 'DataCard1'.Default
    Text: ThisItem.Value
     
    The datacard has the above collection variable SelectedItems in its update section. 
     
    On the OnSelect action for the submit button I have "SaveData(SelectedItems, "SelectedItems");" in that section before the submit form

    On the App properties section for the OnStart I also have "
    LoadData(SelectedItems, "SelectedItems", true);"

    The main issue what is happening is that everyone is saving correctly the first time so when I check the answers for the question and then hit submit.
    the responses are saved successfully but if I reenter the entry and make a change to another field and then save without redoing the checkboxes they get wiped since the variable SelectedItems doesn't get populated on load.

    Thank you again for your help
  • Suggested answer
    narayan225 Profile Picture
    2,449 Super User 2025 Season 1 on at
    Data wiping when I save if I don't make any changes
    I believe you have a gallery screen and the form screen. In that case, you can first collect your data in a collection and display it in the gallery.
    And when you save the form and come back to the gallery screen, you can collect your data from the SharePoint again so that it has the updated values.
    Gallery screen OnVisible:
    ClearCollect(colGalleryData, SharePoint Data Source)
    If you have the same screen gallery and form, you can put the above code inside the Save button or OnSuccess event of the form.
     
    Hope this helps.
    Cheers!
  • Michael E. Gernaey Profile Picture
    40,782 Super User 2025 Season 1 on at
    Data wiping when I save if I don't make any changes
    Hi,
     
    Let me start by saying, I do not know why this works,
     
    Collect(variable, ThisItem), in the code you are literally capturing the entire record. And you say you are doing an updated every single time someone checks or unknocks the checkboxes??
     
    I'd have to see the code, because that's not a normal pattern to do when you are using Galleries.
     
    I do not understand this.
     
    It saves correctly but when I reopen the form and hit save it wipes the data that was saved.
     
    When you open the form from what?
     
    You are confusing what happens so let me try to unconfuse you and myself.
     
    Your App Starts
    You have a Gallery
    in your Galleries Items property you put your Filter/Whatever
     
    In each item that has a Default property, you put ThisItem.ColumnName
     
    For those that have DefaultSelectedItems.
     
    I need more details on your full setup and verify that you have a Choice Column in Dataverse / SharePoint?
     
    Please share more and we can help.

     
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,605 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,946 Most Valuable Professional

Leaderboard