Clone a record with a button : Part 1

Model-Driven App

First we need to create the Entity for the Model-Driven App:

Clone Configuration

Step 1: Create the Entity

Name your entity: wwp_cloneconfiguration and change the Primary Column to Purpose.

Step 2: Add the Following Attributes

  1. Source Entity
    • Type: Single-Line of Text
    • Name: wwp_sourceentity
  2. Source Attributes
    • Type: Single-Line of Text
    • Name: wwp_sourceattributes
    • Note: Extend the maximum length to 4000 characters.
  3. Target Entity
    • Type: Single-Line of Text
    • Name: wwp_targetentity
  4. Target Attributes
    • Type: Single-Line of Text
    • Name: wwp_targetattributes
    • Note: Extend the maximum length to 4000 characters.

Remember that the prefix and names can be changed from you.

Create the form

But what is wrong with it? Having a single line of text results in misspellings, incorrect attributes, and mismatched source and target. It’s a nightmare.

So we use two things.

Firstly
  1. In the Form-Editor go to Components
  2. Select „Get more components“ on the bottom
  3. Switch to „Build by Microsoft“
  4. Search for CC_EntityOptionSet_Name
  5. Add it to the Components

Select it form the Componets Section

Perform the action twice, selecting the corresponding fields (Source Entity/Target Entity) each time. This will generate a new column in the form, which is bound to the selected table column. Consequently, you can remove the Source and Target Entity columns from the form, as they are now displayed as an option set, yet they are stored as a name in the record.

This would look like this now:

However, the issue persists with potential misspellings of the attributes. Unlike the option for Entities, Attributes are not a standard Microsoft component, so what should be done?

This is, where PCF-Controls com’in handy. PCF (Power Apps Component Framework) components are custom user interface elements created using web technologies like HTML and JavaScript, designed to enhance the functionality and user experience of Power Apps.

On the PCF Gallery website, you can find many pre-made PCF controls created by the community. One such control, „Multiple Attributes“ by Ben Thompson, is particularly useful. First, download the control and import it as a solution into your environment. Remember to import it into any environment you use or add it to your solution.

Next, repeat the same steps you followed for the CC_EntityOptionSet_Name. Import the control into the Form, but this time, search for it directly as it won’t be listed under „Build with Microsoft.“ Be aware that your collection of custom controls might exceed some limits.

You should now have it under „More components“ in the Components tab in your form editor.

Then drag it out to your form and adjust all necessary Infos. I have a screenshot for you

This is all you have to do for this Part. In the next Part we will go over the Plugin you need to make to clone a record. And in the thrid part we go over the last Step. Making the Button.

Stay tuned!!

Disclaimer: Since English isn’t my first language, I’ve used AI assistance to correct this article.