Scenario Overview

In this scenario we will show you how to create an email address from a contact's name and their parent account'swebsite URL using regular expressions.

We have a batch of records that contain only the first name and the surname of the contact but they have a parent accountWe will extract the domain name for the email addresses from the parent account's website field and then add them to the first name and last name.

Processing Steps

In this example we are using website URL.

  1. First we remove 'www.' from the website URL if it exists using Replace() function
  2. Next we remove the http:// or https:// if they are on the URL using RegexReplace()
  3. Finally we remove any trailing forward slashes etc. again using RegexReplace()

Start: After the Replace() function: After the first RegexReplace() function: After the second RegexReplace() function:

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • Formula of type 'Save - To Current Record' is created on the Contact entity
  • Source Property is set to 'Firstname, Lastname' and 'Account Name'
  • The Target Property is set to 'Email'

N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a formula of type 'Save - To Current Record' on the Contact entity
  • Set the Source Properties as 'First Name, Last Name' and 'Account'
  • Set the Target Property as 'Email'
  • Copy and paste the formula below into the formula canvas
  • Save and test!


if(ContainsData([contact.firstname], [contact.lastname], [contact.parentcustomerid.websiteurl.?]) and

  /* True */
  [contact.firstname] + '.' + [contact.lastname] + '@' +
      Replace([contact.parentcustomerid.websiteurl.?], 'www.', ''), /* 1 - remove the www. */
      «^.*:\/\/», ''),                        /* 2 - remove the http:// or https:// */
    «\/.*», '')                           /* 3 - remove any trailing /etc after the domain name */
  /* False */

Wizard - DoesNotContainData

Please see below the wizard you can use to create the DoesNotContainData() function call used in this formula. 

Note you will need to either type or paste in the following. 


Did you know?

TestShield automated tests for Dynamics 365 are easily exported/imported

TestShield uses standard Dynamics 365 solutions to package up your configured tests for easy transport and deployment to other Dynamics 365 instances.

This enables use in automated Azure DevOps pipelines where you can automate the build of a Dynamics instance and apply the TestShield solution to execute your tests. 

It also allows you to put your automated tests into source control alongside other customizations.

Learn more about TestShield