Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Patching lookup field in data verse table from a collection

Posted on by

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:

SolTeferi_0-1677538467114.png

Thank you much!

Categories:
  • SolTeferi Profile Picture
    SolTeferi on at
    Re: Patching lookup field in data verse table from a collection

    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

  • Akser Profile Picture
    Akser 1,553 on at
    Re: Patching lookup field in data verse table from a collection

    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

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,297

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,890

Leaderboard