Skip to main content

Notifications

Power Apps - Power Query
Suggested answer

Add related column from lookup for Patch statement

Like (1) ShareShare
ReportReport
Posted on 4 Oct 2024 01:47:54 by 1,141
Hi,
 
I have a use case where I need to Clone an Associated Item (Quote Line Item Calc Table). This is inside a Grid that sits on a form. Main Table is Quote Line Item.
 
Linking the 2 is 
 
The column is not even being used in the raw table.
 
 
What I am not quite sure on is how to add the lookup column (linking column) to the patch statement. Do I need to look it up first? It's displayed in the form. 
 
 
My 1st attempt, thanks to some assistance on this forum will be something like 
 
ForAll(
Self.Selected.AllItems,
Patch(
'Quote Line Item Calcs',
Defaults('Quote Line Item Calcs'),
{
'Quote Line Item':ThisRecord.'Quote Line Item',
'Product Cost':ThisRecord.'Product Cost'
}
)
)
 
However error I am getting on the formula is "invalid argument type (guid). Expecting a record value instead"
 
Thanks in advance for any assistance on this one.
  • Tango Profile Picture
    Tango 1,141 on 08 Oct 2024 at 23:19:03
    Add related column from lookup for Patch statement
    Thanks for your response @Nandit but can quite understand how to expand this to not look for an id of 1 but the current record that is open
  • Suggested answer
    Nandit Profile Picture
    Nandit 1,545 on 05 Oct 2024 at 01:27:13
    Add related column from lookup for Patch statement
    Hi Tango,
     
    To patch LookUp columns, you'll need to provide a record using lookup.
    Also are you trying to patch all the items in a gallery?
     
    Update your formula to something like this:
    ForAll(
    Gallery.AllItems,
    Patch(
    'Quote Line Item Calcs',
    Defaults('Quote Line Item Calcs'),
    {
    'Quote Line Item': LookUp('Quote Line Item', ID = 1), //or any other way of getting the correct record
    'Product Cost':ThisRecord.'Product Cost'
    }
    )
    )
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!

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 #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,238

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard

Featured topics

Loading complete