In Salesforce, record cloning is required to manage business processes, from sales to customer service. Salesforce provides a basic feature for cloning records and their related records, but with the help of flows, we can automate the process of cloning records with their related records.
In this Salesforce tutorial, we will learn to Clone Records with their Related records in Salesforce using Flow. The image below refers to the Screen flow that we will create to clone the Account record with its contacts.

Deep Cloning in Salesforce
In Salesforce, the term Deep cloning is used when we clone the records along with their related records, for example, cloning an Account record with its Contacts or cloning an Opportunity record with the Opportunity members.
This deep cloning of records can be done manually and with automation using the flows.
Clone Records with their Related records in Salesforce using Flow
We will create a Screen flow in the following steps to Clone Records with their Related records in Salesforce.
1. Navigate to the flow builder
Navigate to the Setup page, go to the Quick Find box, and search, then select Flows under the heading Process Automation.
- In the Flow setup window, click on the button New Flow.
- Select the option Screen Flow and click on the Create button.

2. Screen element for user confirmation
Now, we will add a Screen element to the flow that requires user confirmation to clone related records, such as the contacts of the current Account record.
Enter the Label and API Name for the screen element and add a Display text component to the screen.

3. Create a Resource to fetch the current Account Record
To clone an account, we need its ID, so we will create a resource that gets the ID of the current account record. Create a New resource with the following details.
- Select the Resource Type as a Variable.
- Enter the API Name as recordId ( it must be ‘recorId‘ only)
- Select the Data type as Text.
- Activate the checkbox available for Available for Input and click Done button.

4. Add a Get record element to get the account
After this add a Get record element to the flow and the following fields in that.
- Enter the Label and API Name for the get record element.
- Select the Object as Account.
- In the Condition Requirements, select the Field as Id, Operator as Equals, and Value as recordId.

5. Add a Screen element to override the Account name
Now, we will add another Screen element to override the account name of the cloned record. Enter the Label and the API Name for the screen element.
Add a text element to the screen, labeling it Account Name. The API Name will be auto-filled according to the entered label. Then click on the Done button.

6. Add Create Record element to Clone Account Record
- Below the Screen element, add a Create Record element to the flow. Enter the Label and the API Name. After this, activate the radio button ‘Use Separate Resources and lateral values,’
In the Object field, select the Account object.

- In the section, Set Field Value for an account, map the Name field with Account Name (text) and Phone field with Get_record > Account Phone.

- Manually activate the checkbox, assign a variable, and select New Resource in the Variable field.
Enter the below details for the new resource.
- Select the Resource Type as a Variable.
- Enter the API Name as Id_of_cloned_account.
- Select the data type as text and activate the checkbox available for input.
- At last, click Done.

7. Get Record element to fetch Related Contacts of an Account record
To fetch the related contacts of account records, add a get record element to the flow. Enter the below details in the Get record element.
- Enter the Label and the API Name for the get record element.
- Select the Object as Contact.
- Then, in the condition requirements for fetching the Account of Contacts, select the Field as AccountId, Operator as Equals, and Value as recordId.

8. Loop element to fetch all related records
The get record element will only fetch a single contact record; to fetch all associated contacts, we will add a Loop element to the flow.
Enter the Loop element’s Label and API name. In the Collection Variable, select the get record element we created to fetch contacts.

9. Create New Resources to store variable
The loop element will fetch single records in each loop, so first, we will create a resource variable to store a single variable, then we will create a collection variable for the Assignment element.
New Resource for single variable
Create the new resource with the following details.
- Select the Resource Type as a Variable.
- Enter a relevant API Name for the resource.
- Select the Data Type as Record and Object as Contact.
- At last, click Done.

New Resource for collection variable
Create another resource for the collection variable, with the details as follows.
- Select the Resource Type as a Variable.
- Enter the API name for the resource.
- Select the Data Type as Record and Object as Contact.
- Activate the checkbox Allow Multiple Values, and click the Done button.

10. Add an Assignment element for a single variable in the Loop (for each)
Add an Assignment element with the help of which we will assign the first contact that loop is iterating to the single resource variable we created.
Enter the Label and API Name for the Assignment element. After this, map the following Variables with their values.
| Variable | Value |
| SingleContactRecord > Account Name | ClonedAccountId |
| SingleContactRecord > First Name | Current Loop item > First Name |
| SingleContactRecord > Last Name | Current Loop item > Last Name |

11. Add an Assignment element for the Collection variable in the Loop (for each)
Add another Assignment element to create a collection variable of fetched contacts.
Enter the Label and API Name for the Assignment element. In the section Set Variable Values, select the Variable as ContactCollection (collection variable), Operator as Add, and Value as SingleContactRecord (single variable).

12. Create a Record element for Clone Account with related contacts
Finally, add a Create record element and enter the Label and API Name for the Create Record.
In the option to create records, select Multiple.
In the Record Collection, select the record collection that we created for contacts.

Finally, we will add an optional Screen element that displays the message of a successful clone.
13. Save and Activate the flow
At last, save the flow by entering the Flow Label and Flow API Name, then click the Save button.

Click on the Activate button to activate this flow.

Now, the flow is created and activated, and in the further steps, we will test and debug the flow.
Test the created Screen flow
To test the flow, we will create a quick action to call the Screen flow.
1. To create the quick action, navigate to the Object Manager and open the Account object.

2. In the Account object, click on Buttons, Links, and Actions. Then, in the next window, click on New Action.

3. Enter the below fields, to create a new action to call screen flow.
- In the field Action Type, select the option Flow.
- In the Flow field, select the flow that you have created.
- Enter the label for the New Action button and the API Name will be auto-filled. In this case, I have labeled it as Deep Clone.
- At last, click Save.

4. Navigate to the Page Layout of the Account object in the object manager, then open the default page layout, and from the Mobile and Lightning Action, drag and drop the created action ‘Deep Clone‘ to the region Salesforce Mobile and Lightning Experience.
At last, click Save to apply changes.

5. Now open the Account record that you want to clone, and in the quick action tab, click on Deep Clone (created quick action).
6. In the first screen, click Next to confirm the clone, and on the second screen, write the name that you want to override for the cloned account.

7. The current account record and associated contacts will be cloned now. Click the Finish button to complete the flow.

8. Now open the cloned account record, and there you will see the associated contacts.
Here, we can see that the Account record is cloned successfully with its associated contacts.

In this way, we can Clone the Records with their related records in Salesforce using Flow by following the above steps.
Conclusion
In Salesforce, using flows, we can automate the cloning process of records and their associated records. By implementing this automation, we can save a lot of time by avoiding the manual cloning of records, and it clones the records without any errors.
By following the above steps, you might have understood the process of cloning the records with their related records in Salesforce using Flow.
You may like to read:
- How to Clone a Record with Flow in Salesforce
- Salesforce ISCLONE Function
- How to Clone a List View in Salesforce
- Create Record Triggered Orchestration Flow in Salesforce
- Use and Create Flow Screen Radio Button in Salesforce
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.