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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to validate if the...
Power Pages
Unanswered

How to validate if the record is already created in D365Portal

(0) ShareShare
ReportReport
Posted on by 3

Hi,

I have created a page in the D365 portal(customer self-service portal) where user can submit their name and email address.

I want to restrict the users from entering duplicate records, which means if they enter the records once they should not be allowed to enter the record with the same email address.

If they do, there should be a message shown stating that the record is already present. Also, would like to show the status of the existing record along with the message.

 

I tried the below code, however, it is not restricting and the user can submit duplicate records.

if (window.jQuery) {
(function ($) {
if (typeof entityFormClientValidate !== 'undefined') {
var originalValidationFunction = entityFormClientValidate;
if (typeof originalValidationFunction === "function") {
entityFormClientValidate = async function () {
var isValid = await originalValidationFunction.apply(this, arguments);
if (!isValid) {
return false;
}
var inputEmailAddress = $("#emailaddress").val();
try {
const data = await ajaxRequest(`/_api/new_entityname?$select=new_entitynameid&$filter=emailaddress eq '${inputEmailAddress}'`);
console.log(data);
if (data.value.length > 0) {
alert("The email address already exists.");
return false;
} else {
return true;
}
} catch (error) {
console.error("There was an error with the AJAX operation:", error);
return false;
}
};
}
}
})(window.jQuery);
}

function ajaxRequest(url) {
return new Promise((resolve, reject) => {
$.ajax({
type: "GET",
url: url,
contentType: "application/json",
headers: {
"Prefer": "odata.include-annotations=*"
},
success: function (data, textStatus, xhr) {
resolve(data);
},
error: function (xhr, textStatus, errorThrown) {
reject(xhr);
}
});
});
}

Categories:
I have the same question (0)
  • EmadBeshai Profile Picture
    806 Moderator on at

    Hi @Kristy7  , 

    For more effective validation, I recommend using backend validation.

    When creating or updating a record, consider registering a real-time plugin or workflow. This will display any necessary error messages on the portal as you type within your plugin or workflow.

     

    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. 

     

     

    @Kristy7

  • oliver.rodrigues Profile Picture
    9,471 Most Valuable Professional on at

    Have you considered using Alternate keys? Work with alternate keys (Microsoft Dataverse) - Power Apps | Microsoft Learn

     

  • Kristy7 Profile Picture
    3 on at

    Hello @OliverRodrigues ,

     

    Thank you for the idea. I tried the alternative keys and it is working as expected. I would like to know if is there any option to alter the error. Also, I want to show the status of the existing records with the same email address to the user. Is there any possible way to achieve this?

  • Fubar Profile Picture
    8,491 Super User 2026 Season 1 on at

    @Kristy7 Alternate key will only stop the creation of a duplicate, you do not get any additional info etc.  If you want to return data about found records, they you would either need to:

    Personally, I would use the Portals Web API.

  • EmadBeshai Profile Picture
    806 Moderator on at

    Hi @Kristy7,

     

    The Alternative Keys will only show the OOB validation without controlling on it from your side, so if you want to customize the error message then you can use the real-time Plugins or the Custom Workflow to set your custom 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. 

  • oliver.rodrigues Profile Picture
    9,471 Most Valuable Professional on at

    Don't want to disagree with the guys above, but I find a bit overkill creating a plug-in for this when there is an OOB functionality for that.

    I would simply apply JS to the page and replace the error message. Not the most sophisticated, but sometimes it's all we need. 

  • Fubar Profile Picture
    8,491 Super User 2026 Season 1 on at

    @OliverRodrigues agree Alt Key is the way to go if all that is wanted is to stop creation of duplicates.  However the OP also wants to show data from the existing matching record - only way to get that extra info is plugin, web api, power pages flow, or old style ajax call to web page with fetchxml outputting JSON.

     


    @Kristy7 wrote:

    Also, would like to show the status of the existing record along with the message.

     


     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Valantis Profile Picture

Valantis 59

#2
11manish Profile Picture

11manish 51

#3
Haque Profile Picture

Haque 28

Last 30 days Overall leaderboard