Wednesday, April 28, 2010

MSCRM: Cascading Relationship Types

If you re-assign a contact record, what happens to any opportunities where that contact represents a potential customer? For certain entity relationships, you can control this by changing the cascading behavior.

In Microsoft CRM, the behaviors assigned within entity relationships describe what actions should cascade down to related records. Certain system entity relationships for the Account and Contact entities appear to have conflicting cascading relationship definitions.

For example, there are two entity relationships between the Contact entity and the Opportunity entity. When you open each entity relationship, however, you can see details about how they are configured:

* Select Settings > Customize Entities
* Click Contact > Click 1:N Relationships
* Sort by Related Entity > Note Opportunity relationships
* When you open these relationships, you will see:

opportunity_customer_contacts | customerid | Cascade None | No
opportunity_primary_contacts | contactid | Cascade All | Yes

Based on these settings, if you assign a contact that is associated with an opportunity, you should expect Cascade All. The relationship that references the contactid is the only one that matters. If you look at the definition of the Opportunity entity you will see that there is no contactid attribute.

* Click on opportunity_primary_contacts > click on the drop down
* You will see that there are several options in addition to Cascade All

- Cascade All
- Cascade Active
- Cascade User-owned
- Cascade None

These can be customized individually to affect what happens when a contact is associated with an opportunity.

In Microsoft Dynamics CRM, this configuration is needed because there is no actual Customer entity. The Customer is a virtual composite entity where either an account or a contact can be a valid customer.

When the Potential Customer lookup field for an Opportunity record is set, the customerid value is set. Yet when the record is actually saved in the database, the database table column where that value is saved is either the accountid or contactid column, depending on the type of customer. There is no customerid column in the database table for opportunities.

No comments: