Dynamics 365 Sales provides businesses with a centralized platform to manage their customer interactions, account information, and sales processes. With Dynamics 365 you can keep track of your customer accounts and contacts by allowing your team to store and access all customer-related data in one place.
In Dynamics 365 Sales it is possible to link contacts to accounts. This feature allows you to associate individual contacts with their respective customer accounts, allowing for a more comprehensive view of customer interactions and relationships.
By linking contacts to accounts, you can easily access information about an individual contact’s role within their company, as well as view a complete history of interactions with the entire organization. This information you can use to personalize interactions with customers, track the progress of opportunities and deals, and make informed decisions about future sales and marketing efforts.
Unfortunately, the process of linking contacts is a manually process, where the user who creates the contact have to manually select to which account it belongs. This manual process is time consuming, and often is forgotten along the way, making your CRM database less effective.
Therefore we have come up with a solution to automatically link your customer contacts to your accounts via Power Automate!
The solution to automatically link your contacts to your accounts with Power Automate
First of all, we assume that all your contacts have an email address, and that your customers all have a unique email domain (which should be reasonable!). We will use this email address to build a relationship between your Account and the related contacts.
First of all, we will create a custom field called “email domain” under our account card. Here is an example:
In this field, we will input the email domain of the customer. This will be used in our Power Automate script to link all the individual contacts to the Account master.
Step 1 – Create custom field for email domain
Go to Advanced Settings
Under Settings, click Customizations
Click Customize the System
Under the customization screen, find the entity Accounts and go to Fields
Here we will add our new email domain field by clicking on New
Create the field name, and configure the settings as below
Click Save & Close and return to the previous screen
Now we will go to the Forms section and add our custom field to the accounts form
Note that you can also add the field on other forms if you want, for example the Account Quick Create, so when your sales team creates a new account via outlook, they also will be able to enter the domain field there.
Find your email domain field on the right and drag it to the location you want to have it on the form.
Click Save and Close
Click Publish All Customizations
Now you have the email domain field on your account card, where you can enter the email domain of the customer!
After this step we can now move on to the Power Automate Script.
Step #2 – Power Automate Script to Link Contacts to Accounts
Go to Power Automate and create a new flow
Click Build your Own
We will use a scheduled trigger to keep things simple, so every day our new contacts will be linked to their master account.
Go into the flow and start adding the next step
Next we need to filter out all the accounts where the email domain is not empty:
Next is we need to create an Apply to Each loop so we loop through all the records that we found. We can simply start by adding a Compose to our next step, which will automatically create the loop. We can put our email domain field in the compose.
Next, we want to handle multiple entries in the email domain field. We imagine that some accounts may have multiple email domains, hence we will fill them in under the new field as: domain1.com,domain2.com,domain3.com.
In order for our power automate to process them all, we need to first split our field into separate variables and then loop through them. We first split the string into an array by doing a compose with a split command.
After that we will create another loop by creating an Apply to each on the compose output.
Now we have created the loop neccesary for going through all the acounts and all respective email domains.
The next step is to retrieve all the contacts that have the current selected domain in their email address, and are not yet linked to the Account.
We can do that with a Dataverse List Rows command, and a filter.
Now we have all the contacts that are not yet linked, so we can loop through them and link them.
We start with creating an Apply to All by adding a Compose (the easy way to create an apply to all)
Next we do a quick check if the Contact has not been linked to another account already. (As sometimes maybe user may have an email from a domain linked to customer A, but somehow may still be related to another account in your Dynamics, so we need to check if he/she has not been linked already to another account)
If the Parent Customer ID Value is null, it means the contact is not yet linked and we can proceed with linking it to our Account via a Dataverse Relate action.
We add one more Send Email flow to inform ourselves of a succesful link.
And we are done!
Now we can run the flow and we can see that all the contacts with the same email domain have been succesfully linked:
Complete Flow
Here is a screenshot of our entire flow:
Questions? Leave a message below.
We can also help you build this (and other) flows. Contact us via [email protected] if you need assistance with Power Automate or Dynamics 365 Sales.