How to Clone a Record with Flow in Salesforce

In Salesforce, cloning a record means creating a copy of the record. We can clone a record using a Clone button, but it does not clone the related fields in the record, i.e., the records that are not on the page layout.

In that situation, we can use the Salesforce flow in order to clone a Salesforce record.

In this Salesforce tutorial, we will learn how to clone a record with flow in Salesforce. We create a screen flow and add that flow to the record page, and then we will clone a record with the help of that.

Using Flow to Clone a Record in Salesforce

In Salesforce, flows are used to automate the data process in the org. to streamline it efficiently. We can also use the flows to clone a record. We have a feature to clone records with the help of the Clone button, but it does not clone the related record of any record.

There is another standard button, Clone with Related, to clone the records with their related records but this feature is available for the Campaign and Opportunity objects only. When you need to clone the records of objects like Account, Contacts, and Cases, then you can use the Screen Flow to clone the records with their related records.

In this blog, we create flows to clone single and multiple records in the below sections.

  • Create a Flow to clone records in Salesforce
  • Clone Multiple records using flow in Salesforce

Create a Flow to clone records in Salesforce

To create a flow that will clone records, navigate to the Setup page of Salesforce and follow the below steps.

1. Navigate to the Flow setup. For that, go to the Quick Find box, search for Flows under Process Automation, and select it.

2. In the Flows setup window, click on the button New Flow.

3. Select the option Screen flow and click the Create button.

Create a Salesforce flow to Clone records

4. In the flow, click on the “+” icon and select the option Screen under the heading Add element.

5. Enter the Label of the Screen. For example, I have entered the label Create an Account Clone.

6. After this, drag and drop the Display text to the screen region and add the label for that also; then, in the text area, enter the text that you want to display to the user when they create a clone.

In this example, I have entered a confirmation text in the display text section. At last, click on the Done button.

Create a Clone of Salesforce Record with Flow

7. Now, we will create a variable to get the recordid of the Account record. To create a variable, click on the Toggle button, then click on the New Resource button.

Use Screen flow to create a clone with related records in Salesforce

8. Enter the following details to create a new resource.

  • Select the Resource Type as a Variable.
  • Enter the API Name as recordid.
  • Select Data Type as Text.
  • Activate the checkbox Available for input and click on the Done button.
Clone a Salesforce record with Screen flow

9. Now, to get the record ID of the account record, go to the flow, click the “+” icon, and select the component Get Records.

How to clone a record in Salesforce using Flow

10. In the next window, enter the details to create the get record component.

  • Enter the Label and API Name for the get record component. For example, I have entered the label Get Account Record.
  • In this example, I’ll clone the Account record, so I have selected the Object as Account.
  • In the conditions, select the Field as Id, Operator as Equals, and Value as recordid, i.e., the variable we have created in the above steps to get the id of the current record.
How to Create a Record clone with Salesforce Flow

11. Now, we will create another screen to overwrite the Name of the Cloned account, so below the Get Account component, add a Screen element.

In the New Screen window, enter the label for the screen, then add a text component to the Screen region and name it as Account Name; this component will overwrite the name of the cloned record.

In the same way, you can add other components to write other fields in the cloned record.

At last, click on Done.

Create a Clone of an Account record with Salesforce flow

12. Now, we will add a component that creates a Clone record. For that, click on the “+” icon below the second screen component and select the element Create Records.

Then, enter the name for the Label for this component and, after this, activate the radio button Use separate resources and lateral values.

After this, select the object Account.

Use Salesforce flow to clone an Account record

13. On the same page, we will set field values for the account or object that you have selected. In the Field section, select the object field, and in the Value section, select the value for that field.

There are two options to map the value: either the variable you have created or the Get Account element. Here, for the name field, select the Account name value from the screen component that we have created in the above steps.

If we select the name from the get element, then it will name the cloned account as the current account, and that will return an error.

The rest of the fields that you don’t want to over-write can be mapped with get account element values.

How to clone a record using flow in Salesforce

14. At last, click on the Save button, then enter the Label of the Screen flow and click Save.

Clone a Salesforce record with Flow

15. To check the errors and the working of the flow, click on the Debug button at the top of the screen.

How to Create a record Clone in Salesforce using a Flow

16. In the Record ID, enter the ID of the account from which you want to create a clone and then click the Run button.

The ID will be the 15-digit code that you will get from the URL of the account record.

Use Screen flow to clone a Salesforce account

17. We will see the first screen of the flow; here, click the Confirm/Next button.

Create a Clone with the related records in Salesforce

18. In the second window, we can see that the flow has fetched the details of the entered account. On the second screen, enter the name of the new cloned record and click Next.

Create a Clone of an Account record with related records in Salesforce

19. As we can see, the flow ran successfully, and in the Debug details on the right side, we can see that the clone record is created with the over written name.

Clone a Account record clone in Salesforce using flow

20. These changes will be reflected in the the records of the org. To check the created clone record, navigate to the Accounts tab. Here, we can see the cloned record.

Create Record clone with related records using flow in Salesforce

21. Now, click the Activate button to activate this screen flow.

Create a Flow to clone the records in Salesforce

After this, you need to add this screen flow to the Account record page. This flow can be added using a lightning component or a button that calls it.

How to Launch Flow From Button in Salesforce

In this way, we can clone a record using flow in Salesforce by following the above steps.

Clone Multiple Records Using Flow in Salesforce

To Clone Multiple Records Using Flow in Salesforce, we will create a Screen flow that will loop and collect sets. Now follow the below steps to create the flow.

1. Navigate to Salesforce’s setup page, go to the Quick Find box, search, and select Flows under Process Automation.

2. In the Flows setup window, click on the button New Flow.

3. Select the option Screen flow and click Create.

Clone multiple records using flow in Salesforce

4. Add a Screen element to the flow, then enter the Label and API Name for the screen element. After this, add a Display text component from the Components section to the screen.

Use Screen flow to clone multiple records in Salesforce

5. Enter the API Name for the Display text component, then in the rich text area, display the text that you want to display to the user, and click Done.

How to clone multiple records in Salesforce using flow

6. To get the Account Records, add a Get Record element to the flow and enter the below details in it.

  • Add the label and the API name to the get record element.
  • Select Account or the object you want to clone records in the Object field.
  • You can also add conditions for cloning the records. In this scenario, I have added a condition to clone the accounts with the Active field selected as Yes.

You can skip the condition requirements if you want to clone all records.

Clone all records of a Salesforce object using flow

7. To fetch all records, add a Loop element to the flow and enter the Label and API Name for the loop element.

After this, select the Collection Variable as Get Account, i.e., the get record element we created. The loop will run in the account until it gets all records.

Create Clone of multiple records using flow in Salesforce

8. To store the records fetched by loop, We need to create a resource variable so that we can keep all the fetched records in that variable, and we will add that variable to the collection variable later.

To create the resource variable, click on the New Resource button and enter the details below for the new resource.

  • Select the Resource Type as a Variable.
  • Enter the API name for the resource variable. In this scenario, I have named it Accont_detials.
  • Select the Data type as Record and Object as Account.
  • At last, click on the Done button.
Create Clone of multiple records using Screen flow in Salesforce

9. We have created the variable, and now, to assign values to that variable, add an Assignment element in the loop’s section for each.

After this, add the Label and API Name to the Assignment element and map the following variables with their values. Here, Get_details is the Resource Variable name.

To clone the account, we must map the fields Name and Phone; apart from that, you can add additional fields.

Variable Value
Account_details > Account NameCurrent Item Loop > Account Name
Account_details > Account PhoneCurrent Item Loop > Account Phone
How to clone multiple accounts in Salesforce using flow

10. The record variable Get_details will get the values of the account records in each loop, and when it fetches all account records with values, we will store those account records in a collection variable.

Create a New resource and enter the below details to create a Collection variable.

  • Select the Resource Type as a Variable.
  • Enter the API name for the collection variable. I have labeled it as Account_Record_Collection.
  • Select the data type as Record and Object as Account.
  • To store multiple records, activate the checkbox ‘Allow multiple values.
  • At last, click Done.
Clone multiple accounts using flow in Salesforce

11. Now add another Assignment element in the flow for the Record Collection, then enter the Label and API Name for the assignment.

In the section, Set Variable Values, select the Variable as Account_Record_Collection (Collection variable), Operator as Add, and Value as Record_details (a variable that stores records from the loop).

Cloning Multiple Accounts using Flow in Salesforce

12. To create the clone of records from the record collection, add a Create Record element outside the loop and enter the below details.

  • Enter the Label and API Name for the Create Record element.
  • Select the option Multiple because we will create a clone of multiple records.
  • In the Record Collection, select the record collection that we have created.
Use Screen flow to clone multiple Accounts in Salesforce

13. Lastly, I will add a screen to display a success message on the successful cloning of account records, and it is optional to add this screen element.

In the screen element, add a Display text component, enter the API name, and write the message in the rich text area that you want to display to the user after cloning records.

At last, click on the Done button.

Clone all records of a Salesforce object using Screen flow

14. Now click on the Activate button to activate this flow.

How to clone multiple accounts in Salesforce using Screen flow

Now, the flow is created and activated, and in the next steps, we will test its functioning.

Test and debug the created Screen flow

In the below steps, we will test the flow’s functionality. In this scenario, we will add the flow to the home page and then test its functionality.

1. Navigate to the App home page, click on the Settings icon, and select the option Edit Page.

Clone all records in Salesforce using flow

2. In the lightning app builder, drag and drop the Flow component to the template region.

Use Salesforce Flow to clone Multiple records

3. In the Flow fields on the right side, select the flow we have created to clone records and click Save to apply changes.

4. Now, the screen flow will be visible on the home page, and you can see the display text for the confirmation to clone records there. Here, click the Next or Yes button, whatever you have configured in the flow.

Use Salesforce Flow builder to clone multiple Records

5. The next screen will display text that clones are created. Here, click Finish to end the flow.

6. To view the Clone of Accounts records, navigate to the Accounts tab and set the list view to New this week. Then, you will see the cloned Account records as shown in the below image.

This way, we can clone multiple records using Flow in Sale

Conclusion

In Salesforce, flows are useful in creating the clone of the records when we need to create the clone with the related records. In this Salesforce tutorial, we have learned about the process of creating a flow to clone Account records, and later, we create a flow to clone multiple records. This same process can be followed to create clone records of other Salesforce.

We also learned to debug the created flow. By now, you will be able to create flows to clone records in your org.

You may like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.