Clone Dataverse Record(s) Directly From a Model Driven App!
In this tutorial, Nate Halliwell from Pragmatic Works demonstrates how to clone Dataverse records directly within a Model-Driven app using Power FX. This feature is relatively new and can save users from relying on third-party tools or outdated Power Automate actions.
Overview of the Process
Many users have been asking for a way to clone records in Dataverse without third-party tools. Nate addresses this by using Power FX, a low-code formula language in Power Apps. This solution is especially useful since the "For a selected record" action in Power Automate has been deprecated.
Setting Up the Model Driven App
To start, Nate uses a simple model-driven app with a Dataverse table named "YouTube Video Ideas." This table contains fields such as the video name, idea description, goal date, and status. The goal is to create a duplicate of these records without manually inputting the data again.
Steps to Clone a Record
- Edit the Command Bar
To enable the cloning feature, navigate to the left panel in the app, open the tree view, and select the page where you want to add the function. Then, select "Edit Command Bar" to customize the commands on that page.
- Create a New Command
Choose the "New Command" option and decide if you want to create a Power FX or JavaScript function. For this tutorial, Nate focuses on Power FX. This allows the addition of a custom button to clone records.
- Set Visibility Conditions
In the visibility section, configure the button to only appear when records are selected in the grid. Use the
isEmptyfunction to show the button when at least one record is selected. - Using Power FX to Clone Records
The next step is to write a Power FX formula using the
Patchfunction. Nate uses aForAllloop to iterate through the selected records, copying their details to create new entries in the table. - Customize the Patch Function
In the
Patchfunction, thedefaultscommand is used to create new records in the "YouTube Video Ideas" table. Nate demonstrates how to set the "video name" and "description" fields, using concatenation to indicate that the record is a clone. - Testing the Clone Function
After saving and publishing the changes, Nate tests the new functionality. With one or more records selected, the new button appears in the command bar, allowing users to clone records with a single click. The clone records are automatically created with the same data as the original, but with a new name indicating it is a clone.
Conclusion
This solution provides a simple and effective way to clone Dataverse records in a Model-Driven app. It eliminates the need for external tools and offers an easy-to-implement method using Power FX. This method can be especially useful for users working with multiple records or needing to create clones of complex tables with many fields.
By following the steps outlined in this tutorial, users can streamline their workflow and create clones of their Dataverse records with ease. The method Nate demonstrated is an excellent addition to any Power Apps developer's toolkit.
About Pragmatic Works
Pragmatic Works provides training, resources, and expert-led lessons on Power Apps and the broader Microsoft Power Platform. To learn more, check out their other tutorials and training programs.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Model Driven App and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.
Sign-up now and get instant access
ABOUT THE AUTHOR
Nate Halliwell is a Power Platform enthusiast, specializing in Power Apps and Power Automate. He began his journey into the Power Platform as a “Citizen Developer” while working as a recruiter in talent acquisition. He used Pragmatic Works to train himself on the technology and hopes to use this new role as a trainer to help others achieve similar career transitions! Nate is PL-900 and PL-100 Certified, and ready to help you take on any Power Apps or Power Automate challenges you or your organization are currently facing! Outside of work, Nate is a husband, a father to 2 boys, and a beer league hockey player.
Free Community Plan
On-demand learning
Most Recent
private training

Leave a comment