People frequently want to create a new record based on an existing record. This can save a lot of time that would otherwise be spent entering data.
There have been a number of solutions to enable this functionality in earlier versions of Microsoft Dynamics CRM, but these solutions generally require the creation of custom buttons and JScript code.
However, in Microsoft Dynamics CRM you can achieve the same result without writing any code at all. This article describes how to add the capability to "clone" a Lead record, but the same principles can be applied to just about any kind of record in Microsoft Dynamics CRM.
The basic procedure is:
- Create a self-referencing relationship.
- Configure relationship mappings.
- Save and publish the entity.
- Create a cloned record.
Note
You must have the System Administrator or System Customizer role to perform these steps.
Create a self-referencing relationship
- In the Navigation Pane, click System Settings, click Customization, and then click Customize Entities.
- Locate the Lead entity and double-click it.
- Under Details, select N:1 Relationships and then click New Many-to-1 Relationship.
- Enter the following in the Relationship Definition section:
Field
|
Value
|
Description
|
Primary Entity
|
Lead
|
This creates a self-referential relationship.
|
Default Name
|
new_clone_source_lead
|
This must be unique. You can modify it to make it meaningful to people who may see this name when creating reports.
|
- Enter the following in the Relationship Attribute section:
Field
|
Value
|
Description
|
Display Name
|
[This record cloned from]
|
When the relationship is created, the Relationship Attribute is a lookup field that could be added to the Lead form. However, there is no reason to do this. Therefore, provide a display name that indicates clearly what the data in the field represents.
|
Name
|
new_clone_source_lead
|
This name must be unique. You should give it a name meaningful to people who may see this name when creating reports.
|
Description
|
This lookup field is part of the relationship that enables users to "clone" records from an associated view. This field should not be displayed on the Lead form.
|
Record why the field exists. This will help document why the field and relationship are there.
|
- Enter the following in the Navigation Pane Item for Primary Entity section:
Field
|
Value
|
Description
|
Display Option
|
Use Custom Label
|
This indicates that you will specify a label using the Custom Label field.
|
Custom Label
|
Cloned Leads
|
This is the text that will display in the Lead page navigation area so that people can view the associated view created by this relationship. This is where people will go to "clone" a lead.
|
- Click Save, but don't close the relationship form yet.
Configure relationship mappings
After you have created the relationship, you can modify any mappings defined in the relationship. When you create a new record from an associated view, mappings define which data from the current record is copied over to the new record. People can still change the values of the fields before they save the record.
Unless you intentionally want to create a duplicate record, make sure you don't map fields that uniquely identify the source record, such as any name, mobile phone number, or e-mail fields.
Because some fields are automatically mapped when the relationship is created, there are three ways to approach this:
Procedure to remove a field mapping
- In the Mappings area of the relationship form, select one or more attribute mappings.
Tip
You can hold down the Ctrl key and select multiple mappings.
- Click the Delete selected attribute mappings button (the "X" button) in the menu toolbar.
Procedure to map a field
- In the Mappings area of the relationship, on the Actions toolbar, click New for each new mapping.
- In the Create Attribute Mapping dialog box, select the source attribute from Source Entity Attributes, select the target attribute from Target Entity Attributes, and then click OK.
Note
When you select attributes, consider the mapping requirements:
- Both attributes must be of the same type and the same format.
- The length of the target attribute must be equal to or greater than the length of the source attribute.
- The target attribute cannot already be mapped to another attribute.
- The source attribute must be visible on the form.
- The target attribute must be a field that a user can enter data into.
- If the attributes are picklists, the integer values for each option should be identical.
- Address ID values cannot be mapped.
Important
If you want the owner of the new record to be the person who created it, don't map the owner field.
Save and publish
After you have configured the relationship and the relationship mappings:
- Click Save and Close to close the relationship form.
- On the Actions toolbar, click Publish.
Create a cloned record
Now that you have created the relationship and configured the relationship mappings, you can test creating a cloned record.
- Open an existing Lead record.
- Under Details, click the Cloned Leads associated view.
- In the toolbar, click New Lead.
- Confirm that the new lead form fields are populated with the desired data from the source record.
Note
Be sure to check all the tabs.
Related Links
Work with Attribute Mappings
Mapping Entity Attributes
Entity Relationships
Understanding Hierarchical Entity Relationships
Entity customizations