Clone CRM Records using Workflows
Why Clone Records?
Sometimes, it can be time-consuming to create Dynamics CRM records. And in most cases, this isn’t a bad thing: it takes time to enter good data, and the more care taken when entering them, the more useful your CRM will be!
But sometimes, data entry can be tedious and repetitive with little payback. Suppose you need to enter multiple records, one after another, each of which is only slightly different from all the others. This will depend on the specifics of your business, but I personally see it a lot when entering opportunity records. For example, I recently need to enter seven relatively complex opportunity records, each of which represented a specific (billable) part of a large project. There were about 10 fields that would contain the same value for all these records, and 2 that would be different.
What I needed to do here is to “clone” a record: create a new record based on an existing one, and copy some or all of the field values. There’s no out of the box way to do this in Dynamics CRM 4.0, but there are some easy customizations you can use to do it. Here are the two I use the most, each of which should be in your bag of Dynamics CRM tricks:
-
You can create a one-to-many relationship from an entity to itself. (This might sound a little existential, but it’s not. It’s actually self-referential. Sorry, I couldn’t resist.) I discussed and demonstrated that approach in this article.
This “self-referential” approach creates a parent-child relationship between the record you clone and all the records you create from it, and you “map” the fields whose values you want to copy. In certain situations this might be what you want, but not always. In the opportunity scenario I sketched out above I didn’t want it: the opportunity record I started with wasn’t a parent record to any of the others, it just happened to be the first one I entered.
- For situations like the one I’m describing here, you can use a simple manual workflow to create all the similar records you need. It can be a one-action workflow that simply creates a record of the same entity type, and populates the field values you want copied with their values on the record the workflow was run against.
Cloning Records with the Workflow Approach
Here’s the step-by-step process I used to create the “Clone Opportunity” workflow:
-
Create a new blank workflow, selecting Opportunity in the Entity list:

-
This is going to be a manual workflow, so uncheck the “Record is created” default, and check “On demand”.

-
I usually collapse the Workflow Properties area, by clicking the Hide/Show toggle switch. Anyway, pull down the Add Step menu and select the Create Record action. After you do that, click the Set Properties button you will see.

-
Then you just need to fill in the fields on the record the workflow will create…with the corresponding values from the existing record. It takes a little practice to get used Dynamic Values in the workflow design environment. In the next figure I’ve selected the “Topic” field in the field drop-down underneath the entity drop-down in the Look for section. Then click Add, then click OK. (Don’t worry, you get used to it after a bit!)

-
Then just fill out any of the other fields you want values copied for. It’s easy since they’ve all got the same name! In the following figure I show all of the fields on an un-customized opportunity form filled in except for the “Est. Revenue” and “Description” fields. Again, the specifics of your business will determine which of the fields you want to fill in from the original opportunity record.

- Click Save and Close. Then you can publish the workflow and you’re ready to go.
Once it’s published, it’s easy to use. Just create a record you want to copy, and since the workflow was published as an “On demand” workflow, a “Run Workflow” button will now show up on the form toolbar, like this:

You can just clone the same record by running the workflow multiple times, or modifying a cloned record and then cloning it…experiment and see which way is quicker for you. Here are a few records I cloned in this way, just to show an example of what it might look like when you’re done.

The example I showed here was a simple one, but even so, having a “clone record” workflow I can use will save me some time. In the real world, organizations tend to have highly customized opportunity entities with a lot more fields that need to be filled in. So if you ever need to create similar opportunities out there in the real world, this trick might save you some time!
I wrote a book on Dynamics CRM workflows, by the way, and it contains tons of examples like this one and other useful workflows. You can purchase the book on Lulu.com or on Amazon, and if you do, you can also get a (free) subscription to the online version of the book, where you can download the workflows themselves, customizations, and related content.
Here’s a link you can visit to find out more about my book and purchase it:



Brought to you by Richard Knudson and IMG.
Dawid Kolodziejczyk Said,
August 31, 2009 @ 12:16 pm
Is it possible to copy object with related objects just using workflows?
For example Quote with Quote Products.
Richard Knudson Said,
August 31, 2009 @ 12:24 pm
Hi David — No, unfortunately, I don’t think that’s possible with the built-in workflow functionality alone. If you go into the workflow Step Editor and use the Create Record workflow action, you’ll notice you can’t create records such as Opportunity Product, Quote Product, Order Product or Invoice Product. I wish you could!
Are you familiar with the “Get Products” function available on the Quote entity? You can use this to bring over to the Quote record all of the products entered for an existing opportunity record. Depending on what you need, that function can be helpful, and it’s pretty well hidden.
Adam Jewell Said,
October 22, 2009 @ 6:50 am
I’m in the same boat as David. I am trying to devise a user friendly method to “clone” quote products on an existing Quote.
Good article though Mr. Knudson.
Richard Knudson Said,
October 22, 2009 @ 11:00 am
I totally agree — that would be an awesome feature…I just wish we had it! If I come up with anything, I’ll let you know.
Regards,
Richard
Kori Said,
June 25, 2010 @ 10:03 am
i have a workflow that kicks off 20 child workflows to create an estimate. well its doing everything just fine except the data we have in the form properties under onload and onsave event isnt active anymore. its not filling certain fields in on the load of the form like it normally does. can you please help me?
Richard Knudson Said,
June 25, 2010 @ 11:53 am
Hi Kori,
That sounds like quite a workflow, with all those child records! I’ve never implemented one with that many, myself. Do the workflows create new records, and is it those records where you’ve got form script that isn’t firing? If so, that’s the way it works: form script only fires when the form is open. I talk about that in this post: http://www.dynamicscrmtrickbag.com/category/formscript/
And in this one: http://www.dynamicscrmtrickbag.com/2010/05/23/javascript-snippets-1/
Again, not 100% sure if that’s your situation, but it sounds like it might be, and if it is, there’s no real way around it, other than using workflows rather than form script to update your data.
Thanks for reading!