Notifications
Announcements
Hello,
I recently added a 'Copy' button to the main grid in my model-driven app, and here’s how I made it work:
To ensure the button only appears when an item is selected, I used this condition:
!IsEmpty(Self.Selected.AllItems)
Here’s the code I used to copy the selected record, including the lookup field LK_Suppliers:
LK_Suppliers
IfError( Patch( tblProducts, // Data source Defaults(tblProducts), // Creates a new record { LK_Suppliers: Self.Selected.Item.LK_Suppliers, ProductLabel: Self.Selected.Item.ProductLabel, ProductTitle: "(copy) " & Self.Selected.Item.ProductTitle, // Adds "(copy)" to the title ProductQuality: Self.Selected.Item.ProductQuality, ProductGsm: Self.Selected.Item.ProductGsm, IsRound: Self.Selected.Item.IsRound, ProductLength: Self.Selected.Item.ProductLength, ProductWidth: Self.Selected.Item.ProductWidth, ProductDiameter: Self.Selected.Item.ProductDiameter, ProductHeight: Self.Selected.Item.ProductHeight, ProductImage: Self.Selected.Item.ProductImage // Add other fields if needed } ), Notify("Error: Could not copy the product.", NotificationType.Error), Notify("Product copied successfully!", NotificationType.Success) )
Now, when I select a record and click the button, it creates a duplicate of the entry with the specified fields.
Note - I encountered the same issue initially, but it unexpectedly resolved on its own.
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.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Kalathiya 421
WarrenBelz 365 Most Valuable Professional
MS.Ragavendar 339 Super User 2025 Season 2