Query hierarchical data in Dynamics CRM2015

Intro

In Microsoft Dynamics CRM, hierarchical data structures are supported by self-referential one-to-many (1:N) relationships of the related records. In the past, to view hierarchical data, you had to iteratively query for the related records. Presently, you can query the related data as a hierarchy, in one step. You’ll be able to query records using the Under and Not Under logic. The Under and Not Under hierarchical operators are exposed in Advanced Find and the workflow editor.

Examples

The following examples illustrate various scenarios for querying hierarchies:

Query account hierarchy Query account hierarchy Query account hierarchy, including related activities Query account hierarchy, including related activities Query account hierarchy, including related opportunities Query account hierarchy, including related opportunities How to

To query the data as a hierarchy, you must set one of the entity’s one-to-many (1:N) self-referential relationships as hierarchical. To turn the hierarchy on, in Settings > Customizations > Customizer your system > Components > Entity > 1:N Relationships, choose a (1:N) relationship and in the Relationship definition, set Hierarchical to Yes.

Disclaimer: this text is part of the “Administering CRM 2015 for online and on-premises”-Guide, I have not written this myself and do not claim any ownership of it. Moreover this document is provided “as-is”.

Leave a Reply

Your email address will not be published. Required fields are marked *