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 / Forall Patch in Repeat...
Power Apps
Answered

Forall Patch in Repeating Gallery is saving only the first value from a dropdown

(0) ShareShare
ReportReport
Posted on by 62

Hi all,
I have a Data Card that has an "Add" and a "Save" button, and a Gallery in it with 3 controls (A Label and two dropdowns).


The Add button has the following code OnSelect:

Collect( 
NewCollection, 
 { 
 CItemSerialNumber: Text(Last(NewCollection).CItemSerialNumber +1 ), 
 Size: "", 
 Tier: ""
 
 } 
)


The Save button has the following code OnSelect:

ForAll(
 RenameColumns(Gallery2.AllItems, "CItemSerialNumber", "LUN"),
 Patch(
 NewCollection, LookUp(NewCollection, CItemSerialNumber=LUN), ({Size: Dropdown8.Selected.Size, Tier: Dropdown9.Selected.Value})
 )
 )



The Gallery has the NewCollection as Data Source.

 

The problem is whenever I add new records to the Gallery, change their respective Dropdown values and press Save, the Collection creates the new record but doesn't save the dropdown selected value. It selects the first value of each dropdown.
I'm going crazy trying to understand what's going on.

Can you give me a hand?

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Morke ,

    Based on the issue that you mentioned, I think this issue is related to the Patch function within your ForAll formula. For first loop in your ForAll formula, when you execute the PATCH function successfully, the NewCollection would be updated. Because, this repeating Gallery is connected to the NewCollection, your repeating Gallery would be reset, then the Dropdown control within your repeating Gallery would also be reset.

     

    As an fixed solution, please do not add the "Save" button outside the repeating Gallery, instead, you add your "Save" icon inside the repeating Gallery (The "Save" icon would be existed for each item in this Gallery).

     

    Please consider take a try with the following workaround:

    Add a "Save" icon inside your repeating Gallery, set the OnSelect property to following:

    Patch(
     NewCollection, 
     ThisItem,
     {
     Size: Dropdown8.Selected.Size, 
     Tier: Dropdown9.Selected.Value
     }
    )

    or

    Patch(
     NewCollection, 
     LookUp(NewCollection, CItemSerialNumber = ThisItem.CItemSerialNumber),
     {
     Size: Dropdown8.Selected.Size, 
     Tier: Dropdown9.Selected.Value
     }
    )

    Your Repeating Table should be configured as below:

    2.JPG

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • Morke Profile Picture
    62 on at

    @v-xida-msft 

    Thank you for your answer.

    So, it's impossible to save all items from a Repeating Section gallery at the same time?
    That's too bad..

     

    If I add a save button to each section, how can I convert the entire gallery into a JSON, since the Update property of the Data card doesn't take behavioural formulas?

  • Morke Profile Picture
    62 on at

    @v-xida-msft 
    I changed the code to the one you said and the save button still resets the dropdown value to its first value.
    I'm quite lost here.

  • Verified answer
    Morke Profile Picture
    62 on at

    I manage to solve the resetting dropdowns in your formula with a couple of tweaks:

    First, instead of ThisItem, which is referring to the Collection, I used Gallery.Selected

     

     

    Patch(
     NewCollection, 
     Gallery2.Selected,
     {
     Lun: TextInput2.Text,
     Size: Dropdown8.Selected.Size, 
     Tier: Dropdown9.Selected.Value
     }
    )

     

     

    This saved the selected values correctly to the collection table, but the dropdowns visible selections were still resetting

    To fix this, in each dropdown I set the Default property to

     

    ThisItem.'ColumnName'

     

    That prevented the reset.

     

    I'm surprised that you can't save a whole Repeating Gallery with a single button instead of needing to save row by row.

     

    However, I still need to find a way of now saving all the items to a JSON

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

    Hi @Morke ,

    Yeah, I agree with your thought almost. If the solution I provided is also helpful in your scenario, please also consider go ahead to click "Accept as Solution" to identify my solution as helpful.

     

    Best regards,

    Kris

     

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard