Hi,
In Power Apps canvas, I have a collection named "detailCollect". This collection's initial value is defined onSelect of a button and currently, it looks like the following:
Collect(detailCollect,{lookUpProduct:Blank(), transID: Max(detailCollect,transID)+1 , prod:"",quant:0,disp:true})
The focus here is the LookUpProduct field. I have a gallery with its items property set as the collection "detailCollect". The gallery has a dropdown input and a save button. When the save button inside the gallery is clicked/selected, it updates the current record initially defined by the first button located outside the gallery. When that happens, the value of the lookUpProduct field of the collection is replaced by the selected record of the dropdown. The dropdown's items property is a table. The following is what I have for the onSelect event of the save button:
Patch(detailCollect,LookUp(detailCollect,transID=Value(Label9.Text)),{lookUpProduct:Dropdown2.Selected , prod:Dropdown2.Selected.Name,quant:Value(TextInput2.Text), disp:!(Self.Icon=Icon.Save)})
However, I keeping getting error. I tried to replace the Blank() initial value by a record that has the same schema as the table used for items property of the dropdown. But still no success. Does anyone have any idea what I am doing wrong? The error I am getting for how it is current set is the following:
Thank you much!
Hi @Akser ,
Thanks for the reply. I was able to resolve this. I think the lookup column of a dataverse table actually is a record and we have to patch it with a record value. It is not a a simple value as is the case with SharePoint lists. So, I had to use Defaults(Dataverse tableName) to assign an initial blank value to the lookup field of my collection in side the Collect function. We normally use Defaults(dataSource) in side a Patch function. But, it looks like we can use it anywhere to assign an empty record value. So, the formula that I came up with that perfectly worked is the following:
Collect(detailCollect,{lookUpProduct: Defaults(TableName in Dataverse), transID: Max(detailCollect,transID)+1 , prod:"",quant:0,disp:true})
Where "lookUpProduct" is the lookup field which is a record
Hi @SolTeferi,
Your formula currently tries to patch a record (which is the reason you get the error)
Dropdown2.Selected
What happens when you try?
Dropdown2.Selected.Value
//Could also be something else depending on your data source of your drop down control
//Dropdown2.Selected.Result
//Dropdown2.Selected.Name
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.