Hello Experts,
Am new to power Apps and building a canvas app similar to a shopping cart. Am stuck in a stage where am not able to add new records to a SharePoint list that has lookup fields.
My App has two lists. device_Collections and user_orders.

Device_collection has ID, device_name, device_type and device Descriptions field. And this list is loaded to a gallery called Available_Items.
When user selects the add icon in this gallery the record is added to a collection called tmp_1 and is fed as a source for another gallery called user_cart. Where user can modify the quantity or delete the quantity. Finally a Finish Button, that patches all contents in user_cart to the list user_orders.

Problem starts here. user_orders has the following structure, ID, Device_Name which is a mandatory lookup column from device_collections list, and device_type which is auto populated from device_collections list based on the Device_Name field and Order_quantity field. How ever i am able to only update the Order quantity field. Once patch executes Share point list shows Device_Name and device_type columns in user_orders list as Required Info.
Below is code,
ForAll(
user_cart.AllItems,
Patch(
'user_orders',
Defaults('user_orders'),
{
Device_Name: {
Id: LookUp('Device_collection',device_name = ThisRecord.device_name).ID,
Value: ThisRecord.device_name
},
'device_type': {
Id: LookUp('Device_collection',device_name = ThisRecord.device_name).ID,
Value: ThisRecord.device_name
},
'Order_quantity': ThisRecord.Order_qty,
'HO_Order Status':LookUp(Choices('user_orders'.'Order Status'),Value="Odered")
}
)
);
Clear(tmp_1);
Notify("Data Updated Successfully",NotificationType.Success,3000);
I have also tried the following snippet
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
but didn't help much.
If i use the label property in lookup to search for ID i receive a delegate warning
'device_type': {
Id: LookUp('Device_collection',device_name = lbl_devicename.text).ID,
Value: ThisRecord.device_name
},
i tried following couple of articles mentioned online like this PATCH A SharePoint LookUp Column In Power Apps - Matthew Devaney but couldn't find a proper solution. Strangely if i do this with a combo box then the content is updated.