Use Case: Clone Any Objects with Related Lists with Flow

“Clone with related” is an amazing feature which sadly is still not available on custom objects. No worries! This flow solution helps you to clone ANY objects with ANY related lists, and we only use the easiest steps! Let’s dive into how to make that happen!

* Big thanks to Neal Lightfeldt for sending in the case!

Lulu Mobile uses standard Account, Asset, and Contact objects to track their customers’ information. They also have Account Contact Relationship enabled. The sales reps want to be able to clone the Accounts with the option of cloning either Asset or Related Contact lists or both or none.

The flow is not that complicated!

Please don’t be intimidated by the flow charts. The most essential concepts are just Get Records, Loop, Assignment, and Create Records.

Depending on how many related lists you want the users to be able to clone, we need to repeat steps 7 – 13 for the same number of times. For example, in this case we let the user choose between 1) Asset and 2) Related Contact, so we repeated steps 7 -13 for two times.

In the beginning, we use a Screen and Checkbox Group to let users choose which related list to clone. Then, we use that answer in Decision elements. At the end, we add another Screen to let the user link to the newly created record. We will launch this solution as a Quick Action.

Actual Flow: Clone With Two Related Lists

Structure: Unique Steps Of The Flow

Screen FlowAssignmentVariable/Collection
LoopCreate RecordsRecord Id
DecisionGet RecordsScreen Element

Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!

Official Salesforce Help Article On Flow

Subscribe
Notify of
guest

40 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sonia

I’ve tried to duplicate//modify this to copy an opportunity and close products, partners, and contact roles…I didn’t clone the original opportunity, because I wanted to put in a new close date and name…It creates the new opp, but the assign element isn’t assigning the new Opp ID, so it’s adding the products to the original opp. Any ideas/

assignment.jpg
Sonia

I assgned the New Opp Id a variable, added an assignment to the loop to of Current loop ID = New Opp Id, and then added the look to the collection, and created the new from that collection.

steps.jpg
Jonathan

This worked perfectly on the first try! It’s rare that I get any PB/Workflow to work correctly the first time around so it goes to show how well written these steps were. Thanks!!

Cory

Please explain how the original Account ID is being passed into the input variable! Thank you

Mccoy

Hello,

Thank you for this great step-by-step guide! I followed your instructions and was able to create a version of the flow that works perfectly when I run it in Debug mode but does not seem to do anything when I run it for real. Do you have any idea why this might be happening?

Thanks!

Juan

Mccoy, I had the same problem. Have you named the variable as recordId strictly?

Carlos

Hi, I have the same problem, did anyone find a solution?

Marilyn

I’m another person with the same issue. It is creating records in debug, but doesn’t create anything when I use the quick action button. How can I resolve this?

Last edited 2 years ago by Marilyn
Julie

I have the same issue – action created, tied to a button, flow runs and creates a new record, but without the related lists. When tested in debug, flow runs perfectly – creates the cloned record and related lists. Any ideas? Verified API name as recordID.

Miranda

This was such an amazing explanation and it worked perfectly, thank you so much. I’ve used it in several use cases already.
One important thing I noticed is that when you clone the record and related records it keeps the original user, owner and created date. So, in the assignment element, it is very important to mute these, otherwise you might run into some data quality issues later.

Jan

I have a similar use case. I need to clone a record with one related list (what you did) but then i need to add this newly created record to (for example) 50 accounts.

Is there a way to reference the newly created record with the related records and then add that record to multiple accounts?

Zahed

I have use case like this

A,B,C 3 objects
C is child to B
B is child to A

A is having quick action button
When I click this button, then i should clone all A and related B and it’s related C records and should creat new records

With your flow explanation I can able to creat A and it’s related B records. But I am getting error while creating C records.

Whatever the C records are creating,those are linking to original B records not to clone B records.
How to resolve this

Zahed

Based on your flow only I achieved third level also. And my flow working properly. Am able to get related records of child records

Florent lieu

Hi Zahed,
I have exactly the same use case.
I actually have 4 levels.
Have you been succesful using only flow builder or did you use Apex?

Florent lieu

Thank you so much Melody ! Your solution is absolutely great ^^

Fabrizio

Hi, thanks for the post. However,when trying to adapt your flow to my business case (i.e. clone Campaign with Members) I face the following problem: in step “8 Repeat ” you create a “Account Contact Relationship” variable type, which does not seem to have an equivalent for Campaign + Members. I’ve used “Campaign Members” instead, but the flow thorws an error: “DUPLICATE_VALUE: Already a campaign member”. Any suggestions?
Thanks!

Sarah

Fantastic resource, cannot thank you enough. With my first flow, I was able to get a critical business process automated using this article, diagram and steps (I recognize a fellow systems and documentation nerd :). Thank you!!

One question I still have: Although I believed I had put the Create Records element outside of a loop (see screenshot), I am still getting the “tip” that says the following:

Remove Database Access from Loops: A loop contains a/an Create Records element. To avoid reaching per-transaction flow limits, move the “Create New Module Seat” element outside the loop, and have it act on a collection.”
Does anyone know what I need to do here?

Screen Shot 2022-02-11 at 12.15.03 PM.png
Ruby Paul

Hi Melody, thanks for an awesome article. I just created a flow to clone campaign members. It worked like a charm.

2022-03-29 16_53_25-Clone related Campaign members - V1.png
Lucky

I’m unable to get the newly created recordId somehow its redirecting me to the original record id itself. Can you help?

Numinous

Hello Melody, this guide works perfectly, I’ve successfully used it to clone quotes & quote line items. I’ve added this as a custom action to our lightning experience pages, however I would also like to add this as a button. I’ve created a button with a url that links to my flow but when I click on it it goes through the whole checkbox process and then when I click finish, it doesn’t actually clone the quote and just brings me back to the beginning of the flow. I’m guessing that the original quote variable isn’t get passed into the flow correctly.

I would also need the finish button to not bring you back to the flow beginning, but close the pop up window.

Could you offer any assistance here?

Sumit

i keep running into below error when i debug the flow. it happens at the related list create record step. not sure how do I resolves this. there are no duplicates or duplicate rules in place

Error Occurred: This error occurred when the flow tried to create records: DUPLICATES_DETECTED: Use one of these records?. You can look up ExceptionCode values in the SOAP API Developer Guide.—This error occurred when the flow tried to create records: DUPLICATES_DETECTED: Use one of these records?. You can look up ExceptionCode values in the SOAP API Developer Guide.—This error occurred when the flow tried to create records: DUPLICATES_DETECTED: Use one of these records?. You can look up ExceptionCode values in the SOAP API Developer Guide.

Julie

Hi Melody! Thanks for your awesome instructions. I’m having trouble (accidently replied to a users comment below – wrong place) with my action. The flow works perfectly in debug – creates the cloned record and related list. However, when the action executes (from the button tied to the flow), a new record creates without the related list. Any ideas why the action is firing up but not copying the related list? I did verify the API name as recordID. Thanks in advance!

Hema

I had the same exact use case to clone the parent record along with its related records. Everything works exceptionally well. But Why does the cloned record shows the record id instead of a record name?