web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dataverse Custom Butto...
Power Apps
Suggested Answer

Dataverse Custom Button to clone a record with a Lookup column

(0) ShareShare
ReportReport
Posted on by 716
Hello Power Apps community,
 
Can you help please? 
 
My requirement is to create a custom button on a model-driven app where on a form I can click the button and clone the entire Dataverse record. On the record I have two lookup columns, my PowerFX code for the lookup columns is causing an error. If I don't include the lookup column it works perfectly and clones the record. 
 
My record table is called /2Timesheet". The lookup column is called "Invoice" and the table I'm looking up to is called "Invoice". The relationship is many Timesheet records to one Invoice record.
 
Below is the code where I'm getting the error.  The line Invoice: Self.Selected.Item.Invoice is where I'm having the issue,
 
 
Patch(Timesheets, Defaults(Timesheets),
{
    'Timesheet Name': Self.Selected.Item.'Timesheet Name',
    'Date Worked': Self.Selected.Item.'Date Worked',
    'Day Rate': Self.Selected.Item.'Day Rate',
    Invoice: Self.Selected.Item.Invoice
}
);
Notify("Record copied: " & Self.Selected.Item.'Timesheet Name', NotificationType.Success, 5000);
 
The error I'm receiving is attached. 
 
My question is, how in my code can I reference the Invoice column so that it will be added to my copied record?
 
Any help would be greatly appreciated.
 
Garry
invoice error.jpg
I have the same question (0)
  • CU29051324-0 Profile Picture
    4 on at
    Your code looks good - could you please submit the first error showing up in the designer. In you screenshot only the secord error is shown. 
    It could be that when the first error is solved, this second message should be gone.
     
    Dirk
  • Suggested answer
    cha_cha Profile Picture
    4,932 Moderator on at
    Hello CU01081947-0,
     
    Save first your work without the Invoice.
     
    Also, make sure that invoice table is in the app.
  • CU01081947-0 Profile Picture
    716 on at
    Hello @cha_cha,
     
    Thanks for the response. 
     
    I've added the invoice to the table, but still getting the error, even when I save it without the Invoice line.

    ***
     
    Hello @CU29051324-0,
     
    Thanks for the response. The first error I'm getting is this "The function 'Patch' has some invalid arguments." Not much help, sorry.
     
    Garry
  • CU01081947-0 Profile Picture
    716 on at
    Hello @cha_cha, and @CU01081947-0,

    Thanks for your help. I've been able to solve the issue now.

    It's because in the editor of the component library I didn't have Invoice added as a data source. When I added it in, I was able to write the expression and the related column populated on the cloned record. 
     
    I saw this in the video from Scott Durow.
     
    Thanks for your help! 

  • Ram Prakash Duraisamy Profile Picture
    5,631 Super User 2025 Season 2 on at
    HI,
     
    Please find my Github link for cloning the record for the same.
     
    https://github.com/rampprakash/CloneRecordsDynamically

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 386 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 361

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 339 Super User 2025 Season 2

Last 30 days Overall leaderboard