Relationship data analysis with XrmToolBox

Dynamics CRM entity relationship model

Background

Relationships in Microsoft Dynamics 365 Customer Engagement (CRM) and PowerApps Model Driven Apps can be decorated with a number of characteristics that define their behavior. These characteristics instruct the platform how to behave in regard to child data when different actions are taken on the parent record of the relationship.

The configuration of relationships describe what the system shall do when a record is Assigned, Reparented, Shared, Unshared and Deleted. For these actions it is possible to specify if the action shall be cascaded to child records based on their state, owner type, etc. Delete actions can specify that child records shall be deleted, orphaned, or that delete shall not be possible when a parent has children.

 

Challenge

There is no simple way in the platform to see what effect the different actions will have, or even what effect they actually had after the action was performed. The only way is to look at the metadata of the relationships, a feature that normal users cannot access.

You may get stuck where you are prevented from deleting a record if there are relationships with Delete behavior: Restrict. This behavior means that it will not be possible to delete the parent record if there are any child records present in the system. The message from the platform will only tell you that it cannot be deleted, without any information of what is really preventing the delete.

Too late, you could realize that reassigning an event in your event management system does not reassign participant reservations and associated tasks, because the relationship was set to Assign: Cascade None.

After sharing an account with a team mate you may discover that it also made all otherwise classified cases available to the colleague, when the relationship had behavior Share: Cascade Active.

 

Related Records AnalyzerSolution

The XrmToolBox tool Related Records Analyzer can give insights to the challenges above and many more, before having to resort to crossing fingers and hoping for the best before executing actions on parent records.

Selecting parent record

There are two ways to select record to analyze. If you have the URL of a record, simply paste it into the Url / Search field, and RRA will parse the Url to find the referenced entity and record.

The other way is to first select entity type in the dropdown box. This will show the Quick Find view from CRM below, and then just type the search string into the Url / Search field. When you find the record to analyze, select it in the list.

Related Records Analyzer - Find record

The “Quick Find” in RRA will also allow you to enter a record id (guid) in the search field.

 

Choosing analysis options

Related Records Analyzer - Analysis optionsFirst select which types of relationships to include.

Invisible means relationships defined as not visible on the parent form. Note that this may be overridden in the design of each form in the system.

Select Only with data to exclude relationships in the report where there are no child records resent. Note that all relationships will be investigated, and it is only in the display these will be excluded.

Then check which types of behaviors to analyze. The selection is “excluding”, so behaviors not checked will not be included in the analysis. Example: If you wonder what will happen during Assign/Reparent, check the behaviors you want to investigate in that box, and keep all behaviors checked for Share/Unshare and Delete.

 

Start the analysis

Now hit the Analyze Relations button!

Analyzing relationships in Dynamics 365The analysis process investigates all 1:M relationships on the selected entity, and filters them according to the Analysis Options. For each relationship to investigate, all child records are retrieved from CRM, including the columns from the child entity’s Quick Find view.

 

Interpreting the results

When the analysis is finished, you may see something like this:

Related Records Analyzer - resultsA hierarchy view of the parent record, its relationships, and their child records is shown in the first tab. For child records, the value of the Primary Name Attribute is displayed, but if that attribute does not have a value the guid of the records is shown. In the example above, Reservations and Invoice Data have values assigned to their primary attributes, but Addresses do not.

Right-clicking a record in the hierarchy view gives you options to show details for the record, open it in CRM in the browser, or to select this child record as a new parent record in the parent record selector to the left.

When you select to View details, the tab will shift to the relationship for the right-clicked record, and the selected record will be highlighted.

In this view, you can see details about the relationship such as logical name and behaviors for different actions.

Expanding a record in the hierarchy view will load the next level of “grand children” from that child node, using the options specified above.

Children of child records can be expanded infinitely, as long as the child records have relationships matching the analysis options specified.

 

Links

Download XrmToolBoxthe Swiss Army Knife for anyone working with Microsoft Dynamics 365 / CRM – from www.xrmtoolbox.com.
Install Related Records Analyzer from the Plugins Store in XrmToolBox.

Contribute to the open source code for Related Records Analyzer at github.com/rappen/RelatedRecordsAnalyzer

 

Feedback

If you want more features, submit issues to the GitHub repository:
https://github.com/rappen/RelatedRecordsAnalyzer/issues/

If you need to ask a question or simply give the tool a shout-out, tag me on Twitter at @rappen.

 

Credits

The idea for this tool came from my old colleague and friend Sara that you may reach and follow on Twitter at @saralagerkvist

Displaying detail views is done using NuGet package CRMWinForm, a package containing CRM related utilities and a DataGridView control customized to be able to show CRM data using an EntityCollection as data source. This package is, well, also created by me.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.