- #CRM BOOK ACCOUNT HIERARCHY HOW TO#
- #CRM BOOK ACCOUNT HIERARCHY CODE#
- #CRM BOOK ACCOUNT HIERARCHY DOWNLOAD#
Var leOpportunity = query.AddLink("opportunity", "regardingobjectid", "opportunityid", JoinOperator.LeftOuter) Tracer.Trace("Adding link-entity for regarding opportunity") LeContactAccount.EntityAlias = "contactaccount" Var leContactAccount = leContact.AddLink("account", "parentcustomerid", "accountid", JoinOperator.LeftOuter) Tracer.Trace("Adding link-enitity for contact party account") Var leContact = leParty.AddLink("contact", "partyid", "contactid", JoinOperator.LeftOuter) Tracer.Trace("Adding link-entity for contact party") Var leAccount = leParty.AddLink("account", "partyid", "accountid", JoinOperator.LeftOuter) Tracer.Trace("Adding link-entity for account party") LeParty.JoinOperator = JoinOperator.LeftOuter Var leParty = query.AddLink("activityparty", "activityid", "activityid") Tracer.Trace("Adding link-entity for activity party") Tracer.Trace("Removing triggering conditions") Tracer.Trace("Adding distinct to avoid duplicates") Var regardingId = (Guid)regardingCondition.Values
#CRM BOOK ACCOUNT HIERARCHY CODE#
The code that removes the unwanted filters and adds the new filters looks like this: private static bool ReplaceAccountRegardingCondition(QueryExpression query, ITracingService tracer, ConditionExpression nullCondition, ConditionExpression regardingCondition)
#CRM BOOK ACCOUNT HIERARCHY DOWNLOAD#
I will only go through the actual query manipulation, the rest of the plugin code is available for download at the bottom. I have kept and refactored the plugin from previous article to be able to use both features in the same plugin. In this case we need to evaluate the colorful model above, add required outer joins to activities through the different possible paths from the current account, and add an OR-filter to ensure that at least one of the joined paths are valid. This plugin will be somewhat more complicated than the one from the previous article, where the query should be modified to find activities where the current contact was any kind of party. The query is pasted into FetchXML Builder for XrmToolBox to get a visual representation and an easy way to extend and test the query.īy investigating the model and the objective, the query I want to compose looks like this: I investigate the query being sent to CRM when displaying an account with the new subgrid. The signature in this case is to filter by activities created by null.Ī subgrid is added to the account form, and the new view selected as the default and only available view. In this case I create a view for activities that has a specific signature that identifies it as a query to let our plugin manipulate. I will also use one of the new condition operators available in CRM 2016, the UnderOrEqual condition that provides us the means to dynamically query hierarchical information, in this case account hierarchies.Īs this article expands the concepts of the previous article, you should probably read that one before continuing. It's really not that complex at all, as long as you have a decent knowledge about the entity model we are querying. The approach to the problem is the same as described in detail in my last post, but in this case I will expand the query with a few outer joins to related contacts, opportunities etc. As this article indicates, this has been a problem ever since we left CRM 4.0 behind. Some of you may recognize this model – it is respectfully borrowed from MVP Jukka Niiranen's blog post on this problem: CRM 2011 subgrids ain't what associated views used to be. The goal is to be able to display all activities (yellow boxes) anywhere below any account (blue box) that is opened in CRM.
#CRM BOOK ACCOUNT HIERARCHY HOW TO#
In my previous article I showed how to create a simple plugin to show all directly related activities in a subgrid, and not just activities related through the Regarding field. In this article I will demonstrate how to implement a plugin to extend the possibilities for showing activities that are related through account hierarchy in a subgrid on a Microsoft Dynamics CRM form.