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 / Access gallery item in...
Power Apps
Unanswered

Access gallery item in ForAll loop

(0) ShareShare
ReportReport
Posted on by 284

Hi,

 

How can i access the value of a textbox that is nested within a gallery? What I am trying to achieve is loop though each item in the gallery and get the textbox1 value. to patch to a datasource.

 

I have tried the following. however the loops keeps accessing the first itean of the gallery instead of getting the row relevent to that part of the loop.

ForAll(Gallery1.AllItems, UpdateIf(Collection1, ID = ID, {TOOL: Value(TOOL_TI.Text)}))

 

NOTE: the following works if the collection is replaced with an SQL  database, however I require it to work fo a local collection.

ForAll(Gallery1.AllItems, 
 Patch(EmployeeWorkOrderAssignments,{ID:ID}, {TOOL: Value(TOOL_TI.Text)}
 )
)
Categories:
I have the same question (0)
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    I think PowerApps is confused with the "ID = ID". It needs to know which one belongs to "Gallery1.AllItems" and which one belongs to "Collection1". Try this and see if it helps.

     

    ForAll(Gallery1.AllItems, UpdateIf(Collection1, ID = Collection1[@ID], {TOOL: Value(TOOL_TI.Text)}))
  • AnthonyPhan Profile Picture
    284 on at

    Hi @Jeff_Thorpe

     

    I appreciate the response. I implemented your suggestion. For some reson it is now only referencing the last textbox in the gallery when looping.

  • Meneghino Profile Picture
    6,949 on at

    Another way to dismbiguate is to rename the column in the gallery

    ForAll(RenameColumns(Gallery1.AllItems, "ID", "GalleryId"), UpdateIf(Collection1, ID = GalleryId, {TOOL: Value(TOOL_TI.Text)}))

    However, I think patching a table instead of one row at a time could be a better performing solution, something like this:

     

    Patch(Collection1, ShowColumns(Gallery1.AllItems, "ID"), ShowColumns(AddColumns(Gallery1.AllItems, "TOOL", Value(TOOL_TI.Text)),"TOOL"))
  • Meneghino Profile Picture
    6,949 on at

    Hi @Jeff_Thorpe, the diagnosis seems correct and the suggested direction is correct.

    You must keep in mind however, that unless disambiguation is used, the dominant column is that of the inneremost expression i.e. the last named table.

    Hence ID will mean ID of Collection1, so the solution you suggest should give the same result as ID=ID

    I am not aware of a way to disambiguate a two part table name (i.e. Galler1.AllItems), as would be required, hence my suggestion to simply rename the column.

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    @Meneghino, thanks for the insight. I think I have a better understanding now.

    @AnthonyPhan, based on @Meneghino's feed back I believe this formula will work (at least it did in my test app). If @Meneghino solution doesn't workout for you, give this a try:

     

    ForAll(
     AddColumns(Gallery1.AllItems, "tmpID", ID),
     UpdateIf(Collection1, tmpID = ID, {TOOL: Value(TOOL_TI.Text)})
    )

    It removes the disambiguation by putting the ID value in a temporary column and then the rest of the formula references the temporary column.

  • chico Profile Picture
    638 on at

    This little nugget of info just helped a TON.

  • jnernst Profile Picture
    166 on at

    @Jeff_Thorpe 

    @Meneghino 

    You guys are heroes.

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 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard