Update Child Records for 1:N Relationships with Workflow

By Jim Bertler posted 06-19-2017 01:07 PM

​To complete an integration between Microsoft Dynamics 365 for Sales and another software system, ConnectWise, the requirement is that data would integrate when the Relationship Type on Account was updated from Prospect to Client. This is a pretty straightforward requirement and to complete this we created a workflow that says when an Opportunity is set to ‘Won’, a workflow would run and change the relationship type of the parent account. This would trigger the data integration to move from Dynamics 365 to Connectwise. What complicated this slightly, is that for all the child contacts of the parent account to integrate as well, we needed to create a field on contact for relationship type to update from Prospect to Client as well. The problem here is that out-of-the-box workflows in Dynamics only update N:1 relationships, not 1:N. For example, it is pretty simple to have a field on a contact change then update the parent account. To have a parent account field change and update all of the contacts is less straightforward. The good news is that there is a workflow tool available through ‘CodePlex.’ This tool was originally designed for CRM 2011, but recently we tested and got it to work for the most recent version of Dynamics 365 for Sales. In this blog, I will walk through the steps of setting up and installing the tool.

First, navigate to the website and download the workflow utility tool


Import this solution into your Dynamics environment. Once you have the solution imported make sure you create a field on the contact to match the field on the account. In this scenario, we will create a text field on contact for Relationship Type to match the option set field for Account. This is because we cannot map down an option set to another option set with a workflow, but this will work as a text.

Dynamics 365 for Sales
Now we will need to create the workflow to update the child contact records. This will actually need to be broken out into two workflows. The first workflow will be run on Account and trigger the distribute of the field value to the child records. The second will be a child workflow to update the field on contact. First, create your child workflow. Uncheck the box to say when record is created or field changes, this workflow will be triggered by the parent workflow. Then click the box for run as a child process. Now, update the contact form by clicking Look for: ‘Company Name: (Account) and field Relationship type and add in the correct relationship type field on contact. Save this, and now we will create the parent workflow. For this workflow, click Add Step. Then, you will see on the dropdown ‘AG Utilities’ now that you have imported the solution. Click this, and for the Distributed Workflow choose the child workflow that you created. Now you will need to find the relationship name that links the parent account 1:N relationship with the contact. You can do this by going to Settings - Customizations - Customize the System. The click on the dropdown for Account and click 1:N. In this scenario, the relationship name is ‘contact_customer_accounts.’ Add this to the relationship name on your parent workflow.

Dynamics 365 for Sales

Save and activate both workflows, and your task is complete. Now when you change the relationship type field on Account, it will update on all the contacts for that account.

If you think that a Dynamics CRM system is the next best step for your business, contact Logan Consulting, your Microsoft Dynamics CRM partner of Chicago.