Skip to main content

Notifications

Power Platform Community / Forums / Power Query / Add related column fro...
Power Query
Suggested answer

Add related column from lookup for Patch statement

Posted on by 1,133
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,133 on at
    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,091 on at
    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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Tuesday Tip #2 Global Search…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,008

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,531

Leaderboard

Featured topics