In my canvas app, I have a main form, and a secondary form for child records. When I hit the Add button, the two forms are added to collections using the below formula. I can add multiple child records with using the same Add button.
Collect(
MainCollection,
{
Name: DataCardValue3_1.Text,
Fac: DataCardValue19_1.Selected,
}
);
Collect(
ChildCollect,
{
Location: DataCardValue9.Selected,
Details: DataCardValue10.Text,
ReqNum: varReqNum.'Request Number'
}
);
Once I finish adding, I hit the submit and the following formulas are used. I used a Set to store the main record in a variable (varReqNum) so I can get the record ID to use for the child record.
ClearCollect(
MainCollection,
Set(
varReqNum,
Patch(
'Access Control Main Forms',
Defaults('Access Control Main Forms'),
{
FirstName: DataCardValue3_1.Text,
Facility: DataCardValue19_1.Selected,
}
)
)
);
All seems ok up to this point where I want to patch the child records:
ClearCollect(
ChildCollect,
ForAll(
ChildCollect,
Patch(
'Access Control Details',
Defaults('Access Control Details'),
{
Location: DataCardValue9.Selected,
Details: DataCardValue10.Text,
'Access Details': testvar.'Request Number'
}
)
)
);
It patches fine but they are repeating records and It's because im using the datcardvalue from the child form and not the childcollection. How would I go about referencing the child records in the collection to patch into my dataverse?

Report
All responses (
Answers (