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.