web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to preform a check...
Power Pages
Unanswered

How to preform a check if email address already exists in dataverse table before end user form can be submitted

(1) ShareShare
ReportReport
Posted on by 32

Hi, 

I have created a basic webform for user to populate, there is an email field on the form.  I want to be able to check that the email address being input on the basic form has not already been inputted into the dataverse table before the form is submitted.  If the email address already exists the user should get a message on the screen and the form cannot be submitted. 

 

Can this be achieved with out a plugin?

 

Thanks

Categories:
I have the same question (0)
  • JW-22072146-0 Profile Picture
    40 on at

    Yes, you will need to just create flow that either checks the Dataverse table daily or via trigger. 

     

    However, to make this easier you can setup the page so that no duplicate email addresses can be used on registration. 

     

    If this helps please accept it as a solution! 

     

  • Idesofmarch Profile Picture
    33 on at

    @ahilisa  I'm also working on this problem. Are you using a Power Pages site? If I'm successful I'll let you know. All my research leads to using a webapi call to accomplish this. 

  • aofosu Profile Picture
    105 on at

    @ahilisa There are a few ways to handle this:

    1. Setting the Site Setting "Authentication/UserManager/UserValidator/RequireUniqueEmail" to true will enforce unique emails when a user signs up for the first time.
    2. Setting a key on the contact table for the email attribute: This option will be available if there are currently no duplicates in the email column. Once activated, a server-side plugin will check the uniqueness before allowing the user to submit the form.
    3. Writing a custom pre-validation plugin to check for duplication before the record is created.

    Option number 2 should meet your requirements. The only caveat is that the error message cannot be configured server-side. However, you can use jQuery to rewrite and reposition it on the client-side.

  • rfm1964 Profile Picture
    21 on at

    @ahilisa  I found this in the MSFT documentation. It appears to do what we need. I'm going to try it. Keep you posted.
    How to: Use the portal Web API | Microsoft Learn

  • ahilisa Profile Picture
    32 on at

    @rfm1964 @Idesofmarch @aofosu @TA_Jeremy 

    Hi all, 

    I was able to achieve the duplicate check before form submission by setting a key on the email field and then I used the below code to change the error message that appears.

    The entity key worked well because it is being used on a new entity that did not contain any data already and therefore no pre-existing duplicate records. 

     

     // Change error message for unique key validation
     $(document).ready(function () {
     ChangeUniqueKeyValidationMessage();
     });
    
     var ChangeUniqueKeyValidationMessage = function () {
     var errorMessage = $(".text-danger");
     if (errorMessage.text().indexOf("A record that has the attribute values Email Address already exists. The entity key Email Checker requires that this set of attributes contains unique values. Select unique values and try again.") > 0) {
     errorMessage.text("This email address has already been signed up.");
     }
     };
     });

     

     

  • Idesofmarch Profile Picture
    33 on at

    @ahilisa looks great and thank you. In Power Pages Management, I placed it into the advanced "custom javascript" section of the page that contains the form. However, it's not showing me the alternative error message. Do you have any thoughts on that?

    Thanks!

  • Idesofmarch Profile Picture
    33 on at

    @ahilisa I restarted the site and it worked. Yippy!!!

  • ahilisa Profile Picture
    32 on at

    @Idesofmarch great news, glad it worked. 

     

    I have found when using custom JavaScript it works best to put code into the additional Settings, Custom JavaScript section on the actual form (basic/advanced) rather then on the webpage. Some coding I used didn't work for me when it was placed on the web page under Advanced tab and in custom JavaScript. 

  • Idesofmarch Profile Picture
    33 on at

    My quest continues. I have some duplicates that have a status of inactive. Those need to be ignored. I need duplicate email with status active. I'm looking into a flow with an http post request. It's the only thing I could think of but I'll take any suggestions.

  • EmadBeshai Profile Picture
    806 Moderator on at

    Hi @ahilisa

     

    To get accurate result you can do that from backend and you have two options:

    1- create alternative key on the email field to prevent duplication but that will show you a default error message without any control from your side.

    2- Create plugin on the creation of the record and check on the Dataverse if there is any record with the same email then you can pass your custom error message.

     

    If this post helps you with your problem, please mark this answer as Accepted Solution.

    If you like my response, please give it a Thumbs Up. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard