I have absolutely no idea why this isn't working.
I have a single person's ID number, and am trying to use that to update a field of all records with that same ID in the datasource.
For example: I have Joe Bloggs, whose department is currently Admin. His main record is held in my Staff Table with this current dept:
| Name | Dept | UserID |
| Joe Bloggs | Admin | 1234 |
I then have a sub table that lists all Joe trips in this year:
| Name | Dept | UserID | Trip Destination |
| Joe Bloggs | Admin | 1234 | Paris |
| Joe Bloggs | Admin | 1234 | London |
| Joe Bloggs | Admin | 1234 | Madrid |
| Joe Bloggs | Admin | 1234 | The Moon |
Now, Joe has left the Admin department, and gone to Sales. I need to update both the Department field in my Staff table, and at the same time, update all the records belonging to Joe in the Trips table to also have Sales as their department. Changing the Staff table, where I have a gallery and a patch function is fine. The sub table is the issue. When I change his department, I save the chosen department to a variable called chosenDept (in this case "Sales"). I then need to apply that same choice to all records in the Trips table. My Trips table is really quite large, so I have to filter the datasource down so delegation doesn't become an issue.
I'm using this code:
ClearCollect(recordToChange,Filter('[dbo].[Trips]', UserID = ThisItem.UserID));
ForAll(recordToChange,
Patch(Filter('[dbo].[Trips]', UserID = ThisItem.UserID),
LookUp(
'[dbo].[Trips]', ID = recordToChange[@ID]),
{Department: First(chosenDept).Value}));
My Staff table updates fine, the variable reads "Sales", but the Department field in the Trips table just doesn't change at all. I'm not getting delegation errors or anything. It just does not work. Have I missed out something fundamental?