Saturday 9 February 2013

Dynamics CRM 2011 – Mapping of fields from Opportunity Products to Invoice Products

Recently, one of my customers would like to map couple of common custom attributes during execution of entire sales cycle. They are using the out of the box Dynamics CRM sales process. They have these attributes on Opportunity Product entity and want the same values to be auto populated with rest of the sales cycle. Like, when you create Quote record with Quote Products from an opportunity, the same custom attributes should be filled automatically for Quote Products. Likewise, the custom attributes should be populated when you create an Order with Order Products from a Quote and Invoice with Invoice Products from an Order.

Out of the box you cannot find such mappings on these relationships. So, to achieve this requirement, you can use below trick to generate the hidden mappings URLs.

On your development server/machine you just need to execute below query in SQL Management Studio to find out relationship GUID id for Opportunity Product and Quote Product entities.

SELECT    EntityMapId 
FROM      EntityMapBase 
WHERE     TargetEntityName='quotedetail' AND SourceEntityName='opportunityproduct' 

Use the above GUID in below URL and also change the organization name.


Now, launch internet explorer and paste this URL at address bar. As displayed in below screenshot, you could see the list of all available mappings of the above two entities.


Click on New button to open below field mapping popup. Here, you are free to do your mappings.


In the same fashion, find out the mapping GUIDs for Quote Product to Order Product and Order Product to Invoice Product. Prepare their URLs as explained above and complete the attribute mappings.

Finally, add these entities to your unmanaged solution on your development organization. Export it as a managed solution and import the same on QA and Production environments. The same mappings should be applied to those organizations too. Moreover, the same managed solution can also be imported to CRM 2011 online or partner hosted.

I hope this will be helpful.