In this scenario, we want to ensure the quality of all Contact Addresses. We want to run a check on the addresses in the Contact entity to make sure they do not use the special characters " , ; , < , >
We will run this formula whenever a Contacts Address fields have been changed (or created) . It will catch the changes to the Contact record before they are sent to the database and remove any of the special characters above.
N52 Formula Manager Solution
The Formula Manager solution works like this:
- A formula of type 'Save - Perform Action' is created on the Contact entity
- This Formula will be triggered whenever an Contact is created or any of the fields below are updated
- Address 1: Street 1 Address 1: Street 2 Address 1: Street 3 Address 1: City Address 1: State/Province Address 1: ZIP/Postal Code Address 1: Country/Region
- The formula will search the address fields and remove any of the following characters " ;,<> before the fields are saved to the database
N52 Formula Manager Steps
- Create a new formula of type 'Save - Perform Action'
- Set the Mode to 'Server Side'
- Set Event to 'Create & Update'
- Set Source Entity as 'Contact'
- Set Source Property (by holding Ctrl) to:
- Address 1: Street 1
- Address 1: Street 2
- Address 1: Street 3
- Address 1: City
- Address 1: State/Province
- Address 1: ZIP/Postal Code
- Address 1: Country/Region
- Expand Deployment Settings, click on Pipeline Stage and set it to 'Pre-Operation (Synchronous ) '
- Right-click the Decision Sheet and select Set Sheet Options > Use Target Entity
- Note that if you are on the Formula Editor instead of the Decisions Table, click on Commands >Toggle Editor
- Click on cell A2
- Right click and select Delete > Delete Column
- We don't need any conditions for this example
- Select column B to G
- Right click and select Insert > Insert Action
- Click on cell A2 again
- Go to the Source tab and search for "Address 1: Street 1"
- Select 'Address 1: Street 1'
- Select cell A4
- Click on the X on the right hand side to expand the formula editor.
- Enter ReplaceMultiple(XXX, '",>,<,;', '')
- Highlight the XXX
- Click the Source tab and select 'Address 1: Street 1'
- It now should be ReplaceMultiple([contact.address1_line1], '",>,<,;', '')
- Collapse the editor by clicking on on X in the top right corner again
- Click on cell B2
- Repeat above steps for all address fields, moving to the cells beside the previous.
- Click Save
- You are now ready to test.
TestingTo test this, go to a contact record and enter any of the following characters into one of the address fields from above. When you save, the character will be removed from the record.
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.