Hi tjestesjr,
Building on the great suggestions from Valantis and SpongYe - here is the Microsoft Learn context explaining exactly why the As operator aliasing fixes this.
The ForAll function documentation notes that when you have nested functions like LookUp inside ForAll iterating over the same data source, there can be scope ambiguity. Both the outer ForAll loop and the inner LookUp are referencing ERM.UserResponses, so Power Apps may resolve the UserResponseId field against the wrong scope, causing the LookUp to always match the first record.
The As operator lets you explicitly name each record scope to eliminate this ambiguity:
ForAll(colModifiedUserResponesWeather As colRow,
Patch('ERM.UserResponses',
LookUp('ERM.UserResponses' As sqlRow,
sqlRow.UserResponseId = colRow.UserResponseId),
{
Comment: Coalesce(colRow.Comment, ""),
IsComplete: colRow.IsComplete,
Modified: colRow.Modified,
Modifier: colRow.Modifier,
ResponseValue: colRow.ResponseValue,
ScoringGuideId: colRow.ScoringGuideId
}
)
)
With colRow and sqlRow as explicit aliases, Power Apps knows exactly which record scope each field reference belongs to, so the LookUp correctly matches each SQL row instead of repeating the first.
References:
Found this helpful? Please mark "Does this answer your question?" so others searching for the same issue can find it quickly. A thumbs up on "Was this reply helpful?" or a Like is also much appreciated!