Enable email validation for custom forms
Important
This topic is pre-release documentation and is subject to change.
The email validation feature in Dynamics 365 Sales helps validate the primary email address of contact and lead records. By default, this feature is enabled for the main lead and contact forms in the Sales Hub app. However, if you've customized the main lead form, you must manually enable email validation.
Note
These customizations can be applied only to main forms of the Contact
and Lead
tables.
License and role requirements
Requirement type | You must have |
---|---|
License | Dynamics 365 Sales Enterprise, Dynamics 365 Sales Premium, or Microsoft Relationship Sales More information: Dynamics 365 Sales pricing |
Security roles | System Administrator More information: Predefined security roles for Sales |
Enable email validation
You can add the following customizations for email validation:
- To validate email addresses while an email is being composed, add an event handler to the OnLoad event. If an email address isn't valid, a validation message is displayed.
- To add an email validation icon to the email address field, add the email control to the custom form.
Add an event handler to the OnLoad event
Note
This example uses the Contact
table. Use the same basic steps to add an event handler to the OnLoad
event for the main lead form.
Sign in to the Power Apps portal.
Search for and select your organization's environment.
In the site map, select Tables, and then select the
Contact
table.In the Data experiences section, select Forms, and then select your custom contact form of the Main type.
In the Main form pane that opens on the right, select the Events tab.
In the On Load section, select + Event Handler.
In the Configure Event dialog box, select + Add library.
Add the
DataHygiene/Data/salesdatahygiene_form_notification_library.js
library, and then select it in the list.In the Function field, enter Mscrm.LeadHygiene.DataHygieneNotificationLibrary.emailAddressValidationFormOnLoad.
Select the Pass execution context as first parameter checkbox.
Select Done.
Save and publish the form.
In the Handlers section, notice that the required event handler has been added to the form. Ensure that the email validation feature is enabled. Learn how to enable email validation.
Add the email control
You must add the email control only to the primary email address field.
Note
This example uses the Contact
table. You can use the same steps to add the email control for the main lead form.
Open the contact form as described in the Add an event handler to the OnLoad event section.
In the New Contact form, in the Contact Information section, select Email.
On the Properties tab, in the Components section, select + Component.
In the Add component dialog box, add the ValidatedField_Control component, and then select it.
Select the options for web, mobile, and tablet, and then select Done.
Note
Verify that the Show component on options for Email address (default) are removed.
Save and publish the form.
The email control is added to the email address field. Ensure that the email validation feature is enabled. Learn how to enable email validation.
Can't find the options in your app?
There are three possibilities:
- You don't have the necessary license or role. Check the License and role requirements section at the top of this page.
- Your administrator hasn't turned on the feature.
- Your organization is using a custom app. Check with your administrator for exact steps. The steps described in this article are specific to the out-of-the-box Sales Hub and Sales Professional apps.