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 only upda...
Power Apps
Answered

ForAll patch only updating first record - incorrectly

(0) ShareShare
ReportReport
Posted on by 236

I have the following 2 collections.
col_TodayChecks : A List of checks have already been done at the site today. The ID_Check field is the primary key in my SQL database.
col_InspectTemplate : A list of all inspections that NEED to be done at a site. ID_Chk is set to 1 by default, but needs to be updated to value of ID_Check mentioned above.

CountRows(col_TodayChecks) will always be <= CountRows(col_InspectTemplate)
and all the records in col_TodayChecks will always exist in col_InspectTemplate.


I have tried both a lookup()

 

ForAll(col_TodayChecks,
 Patch(col_InspectTemplate, LookUp(col_InspectTemplate, ID_Room=ThisRecord.ID_Room And ID_Check_Option=ThisRecord.ID_Check_Option),
 {
 ID_Chk:ThisRecord.ID_Check
 }))

 

and a First(Filter())

 

ForAll(col_TodayChecks,
 Patch(col_InspectTemplate, First(Filter(col_InspectTemplate , ID_Room=ThisRecord.ID_Room And ID_Check_Option=ThisRecord.ID_Check_Option)),
 {
 ID_Chk:ThisRecord.ID_Check
 }));

 

...to update the col_InspectTemplate records once the inspection has been performed.
(I need to do this because I need to reference the col_InspectTemplate collection elsewhere in my app where the ID_Chk <>1)

 

In both cases only the FIRST record in col_InspectionTemplate is being updated.
Also - Despite the lookup/filter the first record does not meet the criteria.

 

Using the monitor, I get a 'success' result on the Filter operation, but the detail returns the following.

{
"status": null,
"duration": 0.19999980926513672,
"dataSource": null,
"responseSize": null,
"controlName": null,
"propertyName": null,
"nodeId": null,
"formulaData": {
"script": "",
"spanStart": null,
"spanEnd": null
},
"data": {
"duration": 0.19999980926513672
}
}

Implying (to me) that its not finding the record?


My understanding is that the above should
Go to the first record in col_TodayChecks then
lookup/filter the col_InspectTemplate collection record that meets the criteria
update the ID_Chk field with the value from the current record from col_TodayChecks
Then move to record 2 in col_TodayChecks before going through the process again. (Until all records in col_TodayChecks have been 'assessed')

 

If I patch the values (ID_Room, ID_Check_Option and ID_Check) from col_TodayChecks, to a temporary collection while inside the ForAll loop, I have confirmed that the values from each record in col_TodayChecks are being identified correctly.

 

Its a pitty that I cannot Set / UpdateContext within the ForAll loop to debug the process.

 

Any ideas appreciated.

 

Categories:
I have the same question (0)
  • Verified answer
    turnerj3 Profile Picture
    2,039 on at

     

    @MissingLink ,

    This example shows a slightly different syntax in the lookup. It may be worth a try. Instead of ThisRecord it calls the collection.


    ForAll( allRecords, Patch( mySharePointList, LookUp(mySharePointList, ID: allRecords[@ID]), {Status: "Closed"} );

  • MissingLink Profile Picture
    236 on at

    Thanks @turnerj3  : That is a different way to skin this cat - and it works.

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

#2
Haque Profile Picture

Haque 273

#3
Kalathiya Profile Picture

Kalathiya 232 Super User 2026 Season 1

Last 30 days Overall leaderboard