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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Saving the modificatio...
Power Apps
Answered

Saving the modifications done to a gallery into a SharePoint list

(0) ShareShare
ReportReport
Posted on by 10

Hello,

 

not sure someone already answered this question cause when i do a search i can't find exactly what i need but...

 

I'm creating a form for a SharePoint list. I created different screens linked to different lists. On one of my screens, I have a form, to input new data, and a gallery that shows the data. On top of the form I have a Save button that will save my data tomy sharepoint list and refresh the view so i see the newly input data into my gallery. Formula is :

 

If (NewDisplayMode = DisplayMode.Edit,

  If (!IsBlank(DataCardValue5.Text),SubmitForm(EditForm1); ResetForm(EditForm1); Refresh(Activity),

     Notify("Cannot create record. Missing data.", NotificationType.Error)

  )

,true);

UpdateContext({NewDisplayMode: DisplayMode.Disabled}); UpdateContext({EditDisplayMode: DisplayMode.Disabled})

 

I created Global Variables to toggle the display mode (Form activated/deactivated - Gallery activated/deactivated)

 

the problem i have, If i input new data, it works perfectly (according to my formula). New data is added to sharepoint, it also shows up to my gallery on my form, form is reset.

 

When i try to modify the already created records, so when i activate my Gallery (Form deactivates), if i hit the Save button, nothing is saved to SharePoint. 

 

I guess this is normal since my formula doesn't take this case into account and here is my problem. I tried several things in order to readapt my formula ..... adding a Patch function within a ForAll  as a second test in my condition - I did this several ways but nothing seems to be working.... I also changed the OnSuccess function of the form like this

 

ForAll(Gallery1.AllItems,Patch(Activity,{DPID:varID},{DeptTXT:varDept,ProcTXT:varProc,Act:TextAct}))

 

so when i submit the form it will also submit the changes in the gallery...this doesn't work either.

 

Any Idea how this could be done ?

 

I'm very new to Powerapps and try to figure out what to do. i followed this to do what i want but i'm missing the part that saves the modification of the gallery into SharePoint

 

https://www.briteglobal.com/blogs/community/powerapps-contact-manager-addnewform-editgallery/

 

Hope someone will be able to help...

 

Thanks a lot ! 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,432 Most Valuable Professional on at

    Hi @CedJ123456789 ,

    A bit of a complex process here and I have one initial question - is the Item property of your form Galleryxx.Selected?

    If so, you are not actually seeing your new record on the form - just the input that created it. If you are going to use SubmitForm, on an Edit form, SharePoint needs to know what record to edit, which means you should be re-selecting it from the refreshed gallery.
    You could however use FormName.LastSubmit.ID and patch back on this.

    Before I look further, am I on the right track here?

     

     

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @CedJ123456789 ,

    No mention of editing Gallery data section code is on that blog you followed. Let's finish it.

     

    There are two resolutions to save the edited Gallery data to SharePoint list, you can choose which one suits you.

    1. Save each field modification to the list immediately after the field is changed. Modify the OnChang property of each field as below:

     

    Patch(Activity, ThisItem, {FieldName: TextBoxName.Text})

     

    2. Submit all field modification uniformly by Save button. Modify the OnSelect of Save button as below, If the gallery is edited, use ForAll/Patch function to update the gallery data into Sharepoint list.

     

    If (NewDisplayMode = DisplayMode.Edit,

        If (!IsBlank(LastNameField) && !IsBlank(EmailAddressField),

            SubmitForm(AddNewForm); ResetForm(AddNewForm); Refresh(Contacts),

            Notify("Cannot create record. Missing data.", NotificationType.Error)),

       EditDisplayMode = DisplayMode.Edit,

       ForAll(RenameColumns(Gallery1.AllItems,"ID","CID"),Patch('Test 0910',{ID:CID},{FieldName1:TextBoxName1.Text,FieldName2:TextBoxName2.Text }))

            );

    UpdateContext({NewDisplayMode: DisplayMode.Disabled}); UpdateContext({EditDisplayMode: DisplayMode.Disabled})

     

    Hope this helps,

    Sik

  • CedJ123456789 Profile Picture
    10 on at

    Hello, thanks a lot for your answers.

     

    Let me try to answer both of you...

     

    If i try to Patch, each line of the gallery separately, with a button containing Patch(Activity,ThisItem,{DeptTXT:varDept,ProcTXT:varProc,Act:TextAct.Text}) in the OnSelect property, that works like a charm but I don't want to "validate" my entries line by line, I would like to modify everything i need and hit only 1 Save button to copy all the modifications in the SahrePoint list.

     

    @WarrenBelz : In my ITEM property for the gallery (Gallery1), i have this   Filter(Activity, DPID = Value(varID)) . With this I only show in the gallery the information corresponding to a specific entry i did in another screen. So varID has the ID of the parent item and DPID is the column where this same value is copied for all the correspinding items in my Activity list.

    I see the new value on the form but it's not updated in my SharePoint list

     

    @v-siky-msft : your first point works , i also did this (similar to what i did with the button) but the problem is it will input data as i type it. Since I have to work with versionning, i can't do it this way. 

    Second point is what I already tried to do and was not working but i guess my syntax (even if didn't show errors) was not correct cause you add things i didn't have when i tried. What i did was this :

     

    If (NewDisplayMode = DisplayMode.Edit,

        If (!IsBlank(DataCardValue5),

            SubmitForm(EditForm1); ResetForm(EditForm1); Refresh(Activity),

            Notify("Cannot create record. Missing data.", NotificationType.Error)

        ),

       EditDisplayMode = DisplayMode.Edit,

           ForAll(Gallery1.AllItems,Patch(Activity,Defaults(Activity,

              {Act:DataCardValue5.Text,DeptTXT:varDept,ProcTXT:varProc,DPID:varID})));

     

    UpdateContext({NewDisplayMode: DisplayMode.Disabled}); UpdateContext({EditDisplayMode: DisplayMode.Disabled});

     

    What i don't understand in what you wrote...and maybe that's where the problem is... what is for you ID ? CID ? and Renamecolumns?

     

    ForAll(RenameColumns(Gallery1.AllItems,"ID","CID"),Patch('Test 0910',{ID:CID},{FieldName1:TextBoxName1.Text,FieldName2:TextBoxName2.Text })) 

     

    Thanks both for your precious help !

     

  • WarrenBelz Profile Picture
    156,432 Most Valuable Professional on at

    Hi @CedJ123456789 ,

    My initial questions were to get in my mind where your issue might lie and generally your response to what I asked would go a long way towards that. I operate that way so as not to head off on detailed explanations that may not be relevant.

    Your Item property is what could be usually expected - I just have seen some complex ones in the past that have been the actual root of the issue - that is not so in your case.

    So I can get this straight, you want to use SubmitForm (not Patch which works) to modify a record that you have just created as new and do so without going back to the gallery and re-selecting it with EditForm(FormName) as you would normally do?

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @CedJ123456789 ,

     

    The ForAll code walks through each Item of Gallery, patching the value to the SharePoint record with the same ID each time through the loop.

    RenameColumns function is to change the ID column name to another, e.g. CID, in order to avoid ambiguity.

    Hope this helps.

    Sik

     

     

  • CedJ123456789 Profile Picture
    10 on at

    OH !!! ok it seems to be working now !!!

     

    ok wait, answers first....

     

    @WarrenBelz : Yes simply said. I have a form, and on this form i have a gallery. I add a new input, that should show up in the gallery after submission and update my SharePoint list. And when i modify one or several entries in the gallery, submission should update the SharePoint list.

     

    @v-siky-msft : Your solution seems to be working. It seems what i was missing is that  RenameColumns part. From the quick tests I just did it seems ok. I just have double check something related to my default DisplayMode states (form and gallery show up in Edit when i get to my screen which prevents the save function to work properly). So at the end the solution seems to be (related to my case, of course) :

     

    If (NewDisplayMode = DisplayMode.Edit,

      If (!IsBlank(DataCardValue5.Text),

        SubmitForm(EditForm1); ResetForm(EditForm1); Refresh(Activity),

        Notify("Cannot create record. Missing data.", NotificationType.Error)

      ),

      EditDisplayMode = DisplayMode.Edit,

        ForAll(RenameColumns(Gallery1.AllItems,"ID","CID"),Patch(Activity,{ID:CID},{DeptTXT:varDept,ProcTXT:varProc,Act:TextAct.Text}))

    );

    UpdateContext({NewDisplayMode: DisplayMode.Disabled}); UpdateContext({EditDisplayMode: DisplayMode.Disabled})

     

    Thanks a lot !!! 🙂

     

     

  • WarrenBelz Profile Picture
    156,432 Most Valuable Professional on at

     OK @CedJ123456789 ,

    It seems @v-siky-msft solved this before I had the chance to investigate. I will leave you with them.

  • CedJ123456789 Profile Picture
    10 on at

    No problem, don't worry.

     

    Thanks a lot for your 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard