question

MicheleDuBose-2324 avatar image
0 Votes"
MicheleDuBose-2324 asked MicheleDuBose-2324 commented

JQuery script to prevent duplicate entries in SharePoint displaying as undefined

Hello,

I have SharePoint Server 2016 on premise. I need to prevent duplicate values based on two columns. I've referenced this article: https://www.codeproject.com/Tips/1205585/Unique-Entries-Based-on-Multiple-Columns-in-Sharep. However, my code does not consistently work. Please refer to my code: 188165-testcode.txt

In the console.log, I can see the records returned from my list. However, it also displays, 153 undefined undefined. I assume all records are not returning and therefore showing as undefined. As a result, if I enter data in my list, the record will still save even though it already exists in the list. What's missing?


office-sharepoint-server-developmentoffice-sharepoint-server-itpro
testcode.txt (2.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered MicheleDuBose-2324 commented

Hi @MicheleDuBose-2324 ,
The code in that article only works for single text type columns. You can noticle that columns(Title,Name,Email) used in the aritcle are all text type. While you are using Darte cloumn and Person column. These type columns will not work with the code.

So, you have to change your columns to text type to use the code. Otherwise, you have to use the OOTB that permit only one column at a time to be unique.
188197-image.png


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





image.png (34.5 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RaytheonXie-MSFT,

My columns are both Choice column types. If this code only works for text column types, is there another way to prevent duplicates based on multiple columns that are not text type?

0 Votes 0 ·

Hi @MicheleDuBose-2324 ,
There is no such function to retrieve multiple columns. You can use the Enforce unique values in column setting.
189048-image.png


0 Votes 0 ·
image.png (2.5 KiB)

Hi @MicheleDuBose-2324 ,
Would you tell me whether your issue has been resolved or have any update?
I am looking forward to your reply.

Have a nice day!

Thanks,
Raytheon Xie

0 Votes 0 ·

Hi @RaytheonXie-MSFT

The Enforce unique values doesn't work with multiple columns and the JavaScript doesn't work with choose columns. So, it doesn't seem there is a solution for my issue.

0 Votes 0 ·