Saturday, June 13, 2009

MS CRM 4.0 Entity Mapping and Hidden Mappings

Microsoft has a powerful way to manage automatic attribute mappings from entities created from other entities. Typically we see this in the QOI process where an Opportunity is created, and then a Quote, Order or Invoice can be created from the Opportunity and much of the information is automatically copied from the Opportunity to that Quote, Order or Invoice.

Entity Mapping

If you open up your Opportunity from Customize Entities and look at 1:N Relationships, you can see the opportunity_quotes relationship.

image

If you double click on that you will see mappings. This shows you the names of each source opportunity attribute that is “Mapped” to a target quote attribute when a Quote is created from an opportunity.

image

This is very useful if you want to add custom fields and have those automatically propagated too or if you want to disable any default mappings.

So what about mapping the opportunityproduct? or quotedetail, salesorderdetail, and invoicedetail for that matter?

Hidden Entity Mapping

Step 1. You need the EntityMapId for the relationship that you want to map.

You can manually scan the EntityMapBase table matching against the SourceEntityName and TargetEntityName.

image

Or you can write a select like the one below to get a nice list of Guids to copy and paste into a temporary form.

Select TargetEntityName, EntityMapId from dbo.EntityMapBase
where SourceEntityName = 'opportunityproduct'

image

Step 2. Take the following URL and replace your server name and the EntityMapId of your choice to gain access to the rest of the mappingList editors.

http://localhost:5555/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=3A116CD4-A5EE-DD11-BDF0-0003FFEB167C

image

4 comments:

DigiOz Multimedia said...

Thank you for your blog entry. I have just started customizing a CRM 4.0 Portal, and your entry got me thinking in the right direction in terms of Entity Conversion Mapping of Custom CRM Form Fields.

Much Appreciated!

Pete Soheil
DigiOz Multimedia
http://www.digioz.com

Anonymous said...

Hi,

I want to create a new custom mapping between appointment and opportunity. But in the 1:N Relationships window of Appointment, I cannot get "New 1-to-Many Relationship" Button to create new relationships. Is it really possible to get that?

Thanks.

Mark Kovalcson said...

When you run the following SQL it shows the list of Source Entities that can be configured this way.

SELECT SourceEntityName, EntityMapId
FROM EntityMapBase
where TargetEntityName = 'opportunity'


That list does not include any activities. The same goes for 'incident' even though you can promote an activity to a case as well.

Jamie Miley said...

You can do this in online and in 2011 too:
http://mileyja.blogspot.com/2010/12/map-custom-attributes-from-opportunity.html