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 / For all Gallery patch
Power Apps
Answered

For all Gallery patch

(1) ShareShare
ReportReport
Posted on by 69

Good day

I have a gallery that always consist of four records with various fields. I want to use two of the fields the unique identifier named Website_ID and the Form_URL field values which holds values for the four records to update a corresponding unique identifier in another table named Contacts. The four fields that must be updated in the Contacts table has different names.

My formula is:

ForAll(Gallery1.AllItems, Patch(Contacts, First (Filter (Contacts, Contact_ID =Website_ID)), {Assessment_form1:Form_URL, Assessement_form2:Form_URL,Assessement_form3:Form_URL,Assessement_form4:Form_URL}))

The problem is that the formula does not loop through the gallery- it writes the same Form_URL value to each of the different fields in the Contacts table.

Regards

Alwyn

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

    Hi @AlwynSchutte ,

    Firstly try this

    ForAll(
     Gallery1.AllItems As aPatch
     Patch(
     Contacts, 
     LookUp(
     Contacts, 
     Contact_ID = aPatch.Website_ID
     ), 
     {
     Assessment_form1: aPatch.Form_URL, 
     Assessement_form2: aPatch.Form_URL,
     Assessement_form3: aPatch.Form_URL,
     Assessement_form4: aPatch.Form_URL
     }
     )
    )

    although I am wondering to some degree why yours did not work.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • AlwynSchutte Profile Picture
    69 on at

    Hi Warren

    I used your formula-what it does now it uses the last value- the fourth Form_URL of the gallery and writes this value to all of the different fields in the Contacts table namely Assessment_form1, Assessement_form2, Assessement_form3 and Assessement_form4. When I use my original formula, it uses the second value of Form_URL of the gallery and writes this value to all the fields in the Contacts table.

     

    Regards

    Alwyn

  • AlwynSchutte Profile Picture
    69 on at

    Hi Warren

    Attached is the two columns and values of the Gallery that I use to write to the Contacts table-if that might help you.

    Regards

    Alwyn

    PatchURL.png
  • WarrenBelz Profile Picture
    154,540 Most Valuable Professional on at

    HI @AlwynSchutte ,

    That is not a Gallery - it is a Data Table. Please try it in a Gallery as it should work.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • AlwynSchutte Profile Picture
    69 on at

    Hi Warren

    It was just to show you the data of the Gallery which I am trying to write. I created a separate data table-just to show you the data. I have tried your formula a number of times on my Gallery1 and it keeps writing the same value to the different fields in the contacts table.

    As a temporary measure I got it to work with the following code but it is not ideal:

    Select(Gallery1,1);
    Patch(Applications,First(Filter(Applications,'Contact ID'=Gallery1.Selected.Website_ID)),{'Assessment form1':Gallery1.Selected.Form_URL});
    Select(Gallery1,2);
    Patch(Applications,First(Filter(Applications,'Contact ID'=Gallery1.Selected.Website_ID)),{'Assessment form2':Gallery1.Selected.Form_URL});
    Select(Gallery1,3);
    Patch(Applications,First(Filter(Applications,'Contact ID'=Gallery1.Selected.Website_ID)),{'Assessment form3':Gallery1.Selected.Form_URL});
    Select(Gallery1,4);
    Patch(Applications,First(Filter(Applications,'Contact ID'=Gallery1.Selected.Website_ID)),{'Assessment form4':Gallery1.Selected.Form_URL});

     

    Attached is my Gallery

    Regards

    Alwyn

    Gallery1.png
  • AlwynSchutte Profile Picture
    69 on at

    The Applications table as shown above is a new test table in dataverse I created to test.

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @AlwynSchutte 

     


    @AlwynSchutte wrote:

    ...it keeps writing the same value to the different fields in the contacts table...

     


    Please clarify what you mean by this.

     

    Do you mean the same Record from that Table is being overwritten each time, and instead you are expecting different individual Records to be written, but only the one Record is updated, so you get a result of only one Record being updated - when you expect multiple individual Records to be updated  - is this correct?

     

    Or, do you mean that the correct different individual Records are updated, however, it is using same values instead of different values?

    If so, which of the same values is it using? Does it tend to be stuck on a particular Gallery Item instead of looping through them? If so, which specific Gallery Item's values is it using to update all the Records? (e.g. is it the very first one? the very last one? Something else?) I was wondering if you could clarify it.

     

    or, did you mean something else entirely?

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @AlwynSchutte 

     

    To make your temporary measure better, you can try this:

     

    //pseudocode - not tested
    ClearCollect(tempCollect,{})
    ForAll(Sequence(CountRows(Gallery1.AllItems)),
     Select(Gallery1,CountRows(tempCollect));
     Collect(tempCollect,{});
     Patch(Applications,First(Filter(Applications,'Contact ID'=Gallery1.Selected.Website_ID)),{'Assessment form1':Gallery1.Selected.Form_URL});
    )

     

    I did not test the above, I do not know if it even works.

     

    Even if it somehow works, the above is not a good practice at all, it's just something quick in case you need it in a hurry or something.

    I strongly recommend that you check with @WarrenBelz further on why your issue is occurring.

     

    You should figure out why the formula @WarrenBelz gave originally was not working in your case. I would like you to double check and make sure you did use the original formula given exactly, and that (if needed) you used appropriate values for your scenario. 

     

    I could not see any issue with the formula really, it looks like it should work to me.

     

    However, if it is still not working in your case, even after you checked it again, I would ask you to check with @WarrenBelz  for any further questions on this specific thread, as I do not have much time at the moment to go into an in-depth testing of the formula, ForAll, Gallery.AllItems, etc. for the possible causes of this specific issue.

     

    In order to see if there is some issue, I would need to do some checking in-depth, and it's something I'm not available to do at the moment, so please check with @WarrenBelz for any further assistance on this issue, if it persists.

     

    I hope the revised temporary measure I gave may help you, for the very short term.

  • Verified answer
    WarrenBelz Profile Picture
    154,540 Most Valuable Professional on at

    Hi @AlwynSchutte ,

    Firstly can I assume that both Contact_ID and FormURL are different for each record in the gallery - your screenshot suggests Contact_ID is not. Do you have another unique identifier for the record that is also in the Gallery Items ?

    If so

    ForAll(
     Gallery1.AllItems As aPatch
     Patch(
     Contacts, 
     LookUp(
     Contacts, 
     Identifier = aPatch.Identifier
     ), 
     {
     Assessment_form1: aPatch.Form_URL, 
     Assessement_form2: aPatch.Form_URL,
     Assessement_form3: aPatch.Form_URL,
     Assessement_form4: aPatch.Form_URL
     }
     )
    )

    Also when you say it keeps writing the same value to the different fields in the contacts table - what exactly do you mean by that ?

  • AlwynSchutte Profile Picture
    69 on at

    Good day

    The Gallery has four identifiers named WebSite_ID which are all the same value. Another field named Form_URL has all different values. I want to lookup the Website_ID of the gallery in the Applications table in the field named Contact ID and write the four different values of the Form_URL field in the gallery to the fields named Assessment_form1, Assessment_form2, Assessment_form3 and Assessment_form4. The record in the Applications table is found but the fourth value of the Form_URL field of the gallery is written to all of the fields in the Applications table instead of the four different values.

    Attached the picture will clearly explain what the problem is.

     

    Write to database.png

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 545 Most Valuable Professional

#2
Haque Profile Picture

Haque 314

#3
Kalathiya Profile Picture

Kalathiya 234 Super User 2026 Season 1

Last 30 days Overall leaderboard