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:
  • 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

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
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard