Patch(
ProjectDocuments,
ForAll(colDrawingImport,
{Type:ProjectDocumentType.'Client Documents',
DocumentNumber:ThisRecord.Number,
Project:Bulk_NewDocProjectInput.Selected,
AppStatus:ThisRecord.AppStatus,
Category:ThisRecord.Category,
Priority:Value(ThisRecord.Priority),
ProductionStatus:ProductionStatus.'Not Started'}
));
My second table is a revision history table where there is a lookup column called "Document", this "Document" column looks up from the "ProjectDocuments" table.
When I patch this table on a single item else where in the app (not from my collection), I use the following code which works perfect:
Patch(
ProjectDocRevHistories,
Defaults(ProjectDocRevHistories),
{RevisionHistoryID:NewDocNumberInput.Value&"-"&Right(Concatenate("0" & NewDocRevInput.Value),2),
Document:LookUp(ProjectDocuments,NewDocNumberInput.Value=DocumentNumber),
Revision:NewDocRevInput.Value,
AppStatus:NewDocRevStatusInput.Selected.Value,
DateReceived:NewDocRevReceivedInput.SelectedDate}
);
However, when I try to patch this table for a whole collection and therefore within a "ForAll", I can't work out how to lookup the record to patch the "Document" column.
I have tried so many things, but at the moment I have the following, which is not working:
Patch(
ProjectDocRevHistories,
ForAll(colDrawingImport,
{Document:LookUp(ProjectDocuments,ThisRecord.DocNumber=ProjectDocuments.DocumentNumber),
RevisionHistoryID:ThisRecord.Number&"-"&Right(Concatenate("0" & ThisRecord.Revision),2),
Revision:ThisRecord.Revision,
AppStatus:ThisRecord.RevStatus,
DateReceived:ThisRecord.DateRecived})
)