Sunday, June 10, 2012

Mapping MSCRM fields from Opportunity Product to Quote Product

Mapping MSCRM fields from Opportunity Product to Quote Product

MSCRM has an oversight in the default Opportunity-Quote-Order process in taking fields entered at the Opportunity Product stage and having these mapped to any resulting Quote Product or Order Product records.
This means that any fields (such as the field we added to the Opportunity Product screen to track the Product Number of the Product entered from main post in this category) are not mapped over to the resulting Quote Products on our Quote.
Opportunity Products
List of Opportunity Products
Quote Products
List of Quote Products mapped from an Opportunity
This obviously would be confusing to the end-user!
However whilst MSCRM does not directly list the relationship between a Quote Product and Opportunity Product within the available Customisation User Interface – this relationship (and crucially it’s Mappings) are available to us.
The following steps allow us to add or remove mappings to this relationship, and ensure that our custom Product Number field is mapped across.
STEP 1 - Run a SQL Query against the MSCRM Database (typically X_MSCRM where X is your Organisation Name for the MSCRM Deployment) to determine the GUID Id of the Relationship between the Quote Product Entity and the Order Product Entity.
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='quotedetail' AND SourceEntityName='opportunityproduct'
STEP 2 – Take the output of this SQL Query and insert this into the following URL:
1http://[x]/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=[y]
Where [x] is the URL address of the MSCRM Deployment in question and [y] is the GUID Id output of the SQL Query
STEP 3 – This will present the Relationship Mapping screen for mapping attributes from the Opportunity Product entity to the Quote Product entity:
Relationship Mappings from Opportunity Product to Quote Product
Relationship Mappings from Opportunity Product to Quote Product
From here, any number of mappings can be added to define how the Products attached to an Opportunity are mapped across when a Quote is added to the Opportunity. (obviously any changes or additional mappings will need to be published in usual MSCRM fashion)
The same steps can also be used for controlling how fields are mapped across from Quotes to Orders in a similar fashion:
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='salesorderdetail' AND SourceEntityName='quotedetail'
And similarly how fields are mapped from Order Products to Invoice Products:
1SELECT  EntityMapId
2FROM    EntityMapBase
3WHERE   TargetEntityName='invoicedetail' AND SourceEntityName='salesorderdetail'
This is a useful technique when working with any custom fields in a Opportunity-Quote-Order process in MSCRM.