I am running into errors and issues when trying to patch two different entities with a lookup field. The included screenshots will show most of the story but I will also try to explain.
CDS entities
PURCHASE ORDERS
Name [Text]
PO Number [Whole Number]
Vendor [lookup]
ORDER DETAILS
PO Item Number [AutoNumber]
PO Number [lookup] (to the PO Number field on the PURCHSE ORDERS entity)
Quantity [Whole Number]
Stock Number [lookup]
Patch(
Orders,
Defaults(Orders),
{
Name: "Test3",
Vendor: dd_Vendor.SelectedText,
cr014_ponumber: Value(txt_PONumber.Text)
}
);
ForAll(POItemGallery.AllItems,
Patch(
'Order Details',
Defaults('Order Details'),
{
cr014_ponumber:lbl_POItemPONumber,
Quantity: Value(lbl_POItemQuantity.Text),
cr014_StockNumber: lbl_POItemStockNumber
}
))
I get an "value must be a data entity record" error. I understand the error says it is looking for a record but I am not sure how to get it the correct data.
Thank you in advance for any help that you can provide.
Solved! Go to Solution.
Hi @spsolutionsgrp ,
I think the issue you are facing is how to patch a lookup field into entity.
You can simply understand that the lookup field stores the related records in the parent entity, so try to use LookUp function to retrieve the related record based on the label value in cr014_ponumber and cr014_StockNumber part code.
ForAll(POItemGallery.AllItems,
Patch(
'Order Details',
Defaults('Order Details'),
{
cr014_ponumber: LookUp('Purchase Orders', 'PO Number' =lbl_POItemPONumber)
Quantity: Value(lbl_POItemQuantity.Text),
cr014_StockNumber: LookUp( 'Stock Number Entity', 'Stock Number'=lbl_POItemStockNumber) // replace by the real entity name and column name
}
))
Hope this helps.
Sik
Could you please clarify what you want to do with your patch. It looks like you are trying to do too much at one time. Please look at the Northwind Sample database. It can be downloaded from here. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/northwind-install If you go through the exercise, I believe you will find out how to design your app. It seems very much on point.
Hi @spsolutionsgrp ,
I think the issue you are facing is how to patch a lookup field into entity.
You can simply understand that the lookup field stores the related records in the parent entity, so try to use LookUp function to retrieve the related record based on the label value in cr014_ponumber and cr014_StockNumber part code.
ForAll(POItemGallery.AllItems,
Patch(
'Order Details',
Defaults('Order Details'),
{
cr014_ponumber: LookUp('Purchase Orders', 'PO Number' =lbl_POItemPONumber)
Quantity: Value(lbl_POItemQuantity.Text),
cr014_StockNumber: LookUp( 'Stock Number Entity', 'Stock Number'=lbl_POItemStockNumber) // replace by the real entity name and column name
}
))
Hope this helps.
Sik
Thank you, I tried Filter but forgot about the Lookup function. Thanks
User | Count |
---|---|
26 | |
20 | |
7 | |
6 | |
4 |
User | Count |
---|---|
30 | |
25 | |
15 | |
8 | |
7 |