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

Send us a message

Year after year, we have seen the FetchXML language evolve to provide Dynamics 365 users more and more functionality. This language of course is the one behind the user-friendly querying tool of Advanced Find, which offers many powerful options to filter your data.

Power of Under

A condition that became available with the release of CRM 2015 was Under. This condition returns all records under the referenced record in the hierarchy of its entity context. Please refer to “Hierarchy Visualization in Dynamics CRM 2015” to better understand hierarchy in CRM, but in the meantime, let’s discuss a common business requirement that Under can address.

Let’s focus on the out-of-the-box hierarchy setup with Account – the parent-child relationship within Account that supports the concept of Sub-Accounts. Say we have Account Adventure Works with Adventure Works Chicago and Adventure Works New York as Sub-Accounts.

Of course, we also have another parent-child relationship from Accounts being the Contact entity, Contacts being related directly to one Account. For our example, let’s say three Contacts are linked to Adventure Works, two with Adventure Works Chicago, and one with Adventure Works New York. What do we do if we want to see all six Contacts of Adventure Works, regardless if they are linked to the actual Account or a Sub-Account?!

Behold the power of Under, which we can utilize even across parent-child relationships!

Power of Under

We can see the from the simple Advanced Find query above, we can look for Contacts, where their related Account (“link-entity” via the Company Name attribute), is Under our parent Account Adventure Works. This quickly gives us that list of six Contacts that are all linked to Adventure Works.

Here’s a look at the FetchXML behind the scenes, with the beauty of link-entity and Under highlighted:

<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false”>

<entity name=”contact”>

<attribute name=”fullname” />

<attribute name=”contactid” />

<link-entity name=”account” from=”accountid” to=”parentcustomerid” >

<attribute name=”parentaccountid” />

<filter type=”and”>

<condition attribute=”accountid” operator=”under” uiname=”Adventure Works” uitype=”account” value=”{account
guid}” />





Next time a similar requirement arises, please don’t forget what Under can do for you. Note that this example can be related to other related entities that have proper parent-child relationships and hierarchy configuration set up correctly.

Happy CRM’ing!

Avatar for Joe D365

Joe D365

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