Scenario Overview

In this scenario, we will demonstrate how to set up a Decision Table that you can use when a new Contact is created in your Dynamics 365 instance.

For this article it is assumed that you have at least basic familiarity with Decision Tables and/or have read the following articles:

Note: We will not detail step-by-step instructions here on how to set up Conditions or Actions, please read the above articles if you need detailed configuration steps.

The Business Rules

When a new Contact is created

  • Search for a matching account using the domain part of the contacts email address and the account website field
  • If no matching account is found:
    • Create a new account using information from the contact
    • Set the contact as the primary contact on the account
    • Set the new account as the parent account for the contact
  • If a matching account is found set the existing account as the parent account for the contact

North52 Decision Suite Solution

The North52 Decision Suite solution works like this:

  • Decision Table of type 'Save - Perform Action' is created on the Contact entity
  • The Source Property is set to 'All Properties'
  • The Event is set to 'Create'
  • Exit on First Match is turned On (checked)

The Decision Table


Note: This Decision Table uses parameterized Actions to pass different instructions to the same action thereby eliminating the need to create multiple actions doing slightly differing versions of the same task.

In the SetCompanyAccount action we pass the guid of the newly created account into the action or the guid of the existing account depending on the result of the Existing Account calculation.

We call the Action and pass the parameters as follows: {CreateAccount[[ GetVar('CompanyName'), [contact.mobilephone], 'www.' + GetVar('DomainName'), [contact.contactid] ]] }

  SetAttribute('name', {0}),
  SetAttribute('telephone1', {1}),
  SetAttribute('websiteurl', {2}),
  SetAttributeLookUp('primarycontactid', 'contact', {3})

When the formula is executing it will do the following:

    SetAttribute('name', GetVar('CompanyName')),
    SetAttribute('telephone1', [contact.mobilephone]),
    SetAttribute('websiteurl', 'www.' + GetVar('DomainName')),
    SetAttributeLookUp('primarycontactid', 'contact', [contact.contactid] )

This Decision Table uses a Calculation with Fetch-XML to search if an existing account can be located

Existing Account



    SetVar('DomainName', Split([contact.emailaddress1], '@', 1)),  
    SetVar('FirstDot', IndexOf(GetVar('DomainName'), '.', 0)),   
    SetVar('CompanyName', Capitalize(Left(GetVar('DomainName'), GetVar('FirstDot')))),  

    SetVar('ExistingAccount', FindValueFD('SearchAccountsByWebsite', 'accountid', '?', true, 
                                         SetParams('%' + GetVar('DomainName') +'%'))),



Fetch-XML: SearchAccountsByWebsite

  <entity name="account">
    <attribute name="name" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="websiteurl" operator="like" value="{0}" />

There is also 2 Actions to create the instance of the new Account record if needed and to Update the Contact


    SetAttribute('name', {0}),
    SetAttribute('telephone1', {1}),
    SetAttribute('websiteurl', {2}),
    SetAttributeLookUp('primarycontactid', 'contact', {3})

  SetAttributeLookup('parentcustomerid', 'account', {0})

Below we create a new Contact Joe Smith with an email address

When the record creates we can see that North52 has been populated as the Company Name

When we open the newly created account we can see that the Primary Contact has been set as Joe Smith

If another contact is created with an email address in the same company, the Company Name is set to existing North52 account.

Max Power then appears as another contact for the North52 account.


Did you know?

North52's Decision Suite can help enhance Dynamics Business Process Flows

Sometimes business processes are more complicated and have significant permutations that are not easily managed with the out-of-the-box Business Process Flow (BPF) functionality. With North52 Decision Tables you can create rule dependent task checklists for each BPF stage and not allow users to progress until your rule criteria has been met. 

Learn how we do it in this knowledge base article