I have an app with the main form and a child list. I'm trying to save the collection records to the child list of the app. The foriegn key in the child list is named 'Parent' and is a lookup field to the main forms 'ID' field. The main form submits successfully, however the child records do not submit. The error is below:
"The type of this argument 'Parent' does not match the expected type 'Record'. Found type 'Number'"
My formula is below:
ForAll(OrderDetail,Patch('Construction Order Detail', Defaults('Construction Order Detail'), {Title: Manufacture, 'Item Description': Description, 'Item Master Number': Master, 'Quantity Requested': Quantity, 'Parent': 'CXM Form'.LastSubmit.ID})
Also, when I preview the form an empty blank record is present in the gallery, Im not sure why that's happening either.
Hi@ShawnPelletier
You are missing 'Parent'
Set(
gbllastSubmitted,
Self.LastSubmit
);
Patch(
'Construction Order Detail',
Defaults('Construction Order Detail'),
{
Title: "Manufacturer Part #",
'Item Description': "Test description",
Requested: "10",
'Parent': {
Value: gbllastSubmitted.ID,
Id: gbllastSubmitted.ID
}
}
)
You don't need to use again Form.LastSumit as we have already captured on the variable gbllastSubmitted.
I will recommend you change the name parent to ParentLookup as the Parent normally used within PowerApps formulas. for example,
Set(
gbllastSubmitted,
Self.LastSubmit
);
Patch(
'Construction Order Detail',
Defaults('Construction Order Detail'),
{
Title: "Manufacturer Part #",
'Item Description': "Test description",
Requested: "10",
ParentLookup:
{
Value: gbllastSubmitted.ID,
Id: gbllastSubmitted.ID
}
}
)
OrderDetail (collection):
Construction Order Detail (child list):
I'm trying to patch:
iDescription > Description
iManufacturer > Title
iMaster > Master
iQtyOrdered > Requested
ID of Master form > Parent
Let me know if you need additional screenshots. Thank you.
@ShawnPelletier
Show me a screenshot of your backend SharePoint columns something not right.
Here is what I'm running into now when trying to use the above:
I renamed the child list fields to one word names to avoid issues and confusion with spacing, etc. This code is placed in 'OnSuccess' of the main form submission.
Also, If I'm correct:
Title: refers to child list column name
: 'Manufacturer Part #' refers to the gallery column name assigned to 'Title'
Where and how do the collection column names map into this?
@ShawnPelletier
The reason you're getting the is error is Parent is a lookup so try this on form success
Set(
gblLastSubmitted,
Self.LastSubmit
);
Patch(
ParentList,
Defaults(ParentList),
{
Title: gblLastSubmitted.Title,
'Parent': {
Value: gblLastSubmitted.ID,
Id: gblLastSubmitted.ID
}
}
);
Try this on your end
Set(gblLastSubmitted,Self.LastSubmit);
ForAll(OrderDetail,Patch('Construction Order Detail', Defaults('Construction Order Detail'), {Title: Manufacture,
'Item Description': Description,
'Item Master Number': Master,
'Quantity Requested':Quantity,
'Parent':{Value: gblLastSubmitted.ID,Id: gblLastSubmitted.ID}
});
I usually use set a variable to my patch results and then use that to reference the id.
Set(varNewItem, Patch(<Main Patch Logic Here>));
Then use the variable results in your other expression, so replace 'Parent': 'CXM Form'.LastSubmit.ID} with Parent: varNewItem.ID,
Also check your quotes in your child patch expression, the field names should not be in quotes, so 'Parent' should be Parent.