POWEROBJECTS

718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

With CRM 4.0, the range of entity relationship options has been increased and you can now create the following:

crm2011
Additional CRM 4.0 Entity RelationshipsDescription
One-to-Many System-SystemA system entity is linked to another system entity. The child system entity has a lookup field to associate it with a parent system entity.
Self-ReferentialAn entity linked to itself. For example a Case can be linked to a master Case.
Multiple Relationships Between EntitiesFor example the Account entity might have two relationships with a Contact entity – a primary and secondary Contact
Many-to-Many System-System, System-Custom & Custom-CustomThe one that everyone has been waiting for. Not only will this remove the need to build a “joining” entity, but you have control over how the relationships show up in the UI

The customizations UI will only show entities that are valid for a given kind of relationship. For example, if an entity is not available for N:N relationships the “New N:N..” button won’t appear.

To determine the same programmatically, i.e. whether two entities are eligible to participate in a relationship, the CRM Metadata Web service exposes the following messages:

CanBeReferenced: Checks whether the specified entity can be the primary entity (one) in a one-to-many relationship.

CanBeReferencing: Checks whether the specified entity can be the referencing entity (many) in a one-to-many relationship.

CanManyToMany: Checks whether the entity can participate in a many-to-many relationship.

GetValidManytoMany: Returns the set of entities that can participate in a many-to-many relationship.

GetValidReferencedEntities: Returns the set of entities that are valid as the primary entity (one) from the specified entity in a one-to-many relationship.

GetValidReferencingEntities: Returns the set of entities that are valid as the related entity (many) to the specified entity in a one-to-many relationship.

Sample Code:

public static void relationshipsEligibilityTest(MetadataService metadataService)

{

GetValidManyToManyRequest getValidManyToManyRequest = new GetValidManyToManyRequest();

GetValidManyToManyResponse getValidManyToManyResponse = (GetValidManyToManyResponse) metadataService.Execute(getValidManyToManyRequest);

foreach (string nextName in getValidManyToManyResponse.EntityNames)

{

Console.WriteLine(nextName);

}

}

Avatar for JoeCRM

JoeCRM

Joe CRM is a CRM superhero who runs on pure Microsoft Dynamics CRM adrenaline. As the face of PowerObjects, Joe CRM’s mission is to reveal innovative ways to use Dynamics CRM and bring the application to more businesses and organizations around the world.