Edit Error Message Text


I want to change the text of this error message.

I set the field to have "enforce unique values"

Do you have the code for this?

Dear @DryChips,
No, this particular message comes from SharePoint and cannot be changed.

1 Like

Hi Nikita,

as an alternative, is it possible to use the Pnp.JS library to search for user principal name in the CURRENT list and if it returns true, it displays an error message and shows their record in list/library control?

Here is a video example of what I want to do:

I have added this code in but doesn't work:

//Detects field value change when function is called
  fd.field('User_Principle_Name').$on('change', function(value){

//Function will send Pnp request to search for value in list and let user know if name exists in list
function validateCC(value){
    pnp.sp.web.lists.getByTitle("POWERBiV2").items.filter("User_Principle_Name eq").get().then(function(items){
           if (items.length > 0){
           $($(fd.field('User_Principle_Name').$el).find('input')[0]).attr('style', 'border-color: #6CEE5A;');
           $($(fd.field('User_Principle_Name').$el).find('input')[0]).attr('style', 'border-color: #ff0000;');

I get this error in console:

If I remove the eq from this snippet: filter("User_Principle_Name eq") I dont get any errors in console, but I don't get a browser alert or anything to indicate the value was found in the list.

Dear @DryChips,
It's possible, but you need to use User ID for filtering - How can I filter a list with ODATA for Person or Group Field? - SharePoint Stack Exchange

You'll first need to get the user with pnpjs and get User ID - users - PnP/PnPjs

Hi Nikita,

HR advisors will manually enter the manager's User Principal name into the SharePoint list. I'm not using Person/Group field as the AD list isn't robust enough to use.

Dear @DryChips,
So it's just a text field? Then, it should be easier, just make sure to filter by text value:
filter("User_Principle_Name eq '" + value "'")

1 Like

Thank you!

I was missing the apostrophe's in the code which is why it wasn't working. Can I ask, what the eq means?

Dear @DryChips,
It's short for equals - the filter is part of the OData query, here's the list of all supported OData queries:

Taken from here - Use OData query operations in SharePoint REST requests | Microsoft Learn