Customize Entity and Attribute Mappings
You can map attributes between entities that have an entity relationship. This lets you set default values for a record that is created in the context of another record.
In This Topic
Behavior in the Application
Mapping in Microsoft Dynamics CRM streamlines data entry when you create new records that are associated with another record. When an entity has an entity relationship with another entity, you can create new related entity records by using the Create Related tab in the ribbon. When you create a new record in this manner, mapped data from the primary entity record is copied to the form for the new related entity record. By mapping entity attributes, you control what data is copied by adding new mappings in the relationship between the two entities. If you create a record in any way other than from the associated view of the primary entity, data is not mapped.
For example, you might want to set up a mapping between the address fields in accounts and the address fields in contacts. With this mapping, when a user adds a contact associated with a specific account, the address fields for the contact are populated automatically.
You can map one attribute to multiple target attributes. For example, you can map address information in an account to both the billing and shipping addresses in an order.
Mapping is applied before a new, related record is created. Users can make changes before saving the record. Later changes to the data in the primary record are not applied to the related record.
Using Entity and Attribute Mapping Data
When creating new records in the context of an existing record where a mapping exists between the entities, you can use the InitializeFromRequest message to define a new record that contains the values specified in the mapping. You can then use the IOrganizationService.Create method to save the record. In in this manner, any mappings that you define are applied.
Valid entity maps are created when an entity relationship is created. Use the entity_map_attribute_maps entity relationship to retrieve the attribute maps for the pair of entities specified by the entity map.
You can create or update attribute map records. The following requirements must be met for attribute maps:
The AttributeMetadata type must match.
The length of the target field cannot be shorter than the source field.
The format must match.
The target field must not be used in another mapping.
The source field must be visible on the entity form.
The target field must be a field in which a user can enter data.
Address ID values cannot be mapped.
PartyList attributes, where AttributeMetadata.AttributeType is AttributeTypeCode.PartyList cannot be mapped.
Auto-mapping Attributes Between Entities
You can edit attribute mappings between entities for entity relationships that support mapping.
In addition to creating each attribute map manually, you can use the AutoMapEntityRequest message to generate a new set of attribute mappings. This message performs the action found under the Generate Mappings menu option in the More Actions menu on the toolbar. This message maps all the attributes between the two related entities where the attribute names and types are identical. This message is provided as a productivity enhancement so that you do not have to manually add all attribute mappings. Instead, you can generate a set of likely mappings and minimize the amount of manual work to add or remove individual mappings to meet your requirements.
|Automatically generating mappings in this manner will remove any previously defined attribute mappings and may include mappings that you do not want.|
ConceptsEntityMap Entity Messages and Methods
EntityMap Entity Metadata
EntityMap Entity OptionSet Attribute Metadata
AttributeMap Entity Messages and Methods
AttributeMap Entity Metadata
AttributeMap Entity OptionSet Attribute Metadata
Other ResourcesExtend the Metadata Model
Help Topic: Mapping Entity Fields
Help Topic: Create or Edit Mapping Between Fields
Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2012 Microsoft Corporation. All rights reserved.