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 account. We 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.
In this example we are using http://www.adatum.com/ website URL.
- First we remove 'www.' from the website URL if it exists using Replace() function
- Next we remove the http:// or https:// if they are on the URL using RegexReplace()
- Finally we remove any trailing forward slashes etc. again using RegexReplace()
Start: http://www.adatum.com/ After the Replace() function: http://adatum.com/ After the first RegexReplace() function: adatum.com/ After the second RegexReplace() function: adatum.com
N52 Formula Manager Solution
The Formula Manager solution works like this,
- A 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 DoesNotContainData([contact.emailaddress1]), /* True */ [contact.firstname] + '.' + [contact.lastname] + '@' + RegexReplace( RegexReplace( 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 */ ,'NoOp' )
Wizard - DoesNotContainData
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.