4

I am unable to enforce unique values based on more than one column in list.

Current scenario: I can make a enforce unique values entered in single column unique using OOTB functionality.

What I want to do: I have two column in a list. I want to assure the combination of values from both these columns is be unique. for Example:

Item 1: column1 = "T1" and column2 = "abc"

Item 2: column1 = "T1" and column2 = "cde"

Item 3: column1 = "T1" and column2 = "abc"

For item 3, user should be prompted with a validation and should not be allowed to enter this combination.

What approach should I use?

  • 1
    Could you please elaborate a bit more about what you are trying to do? – Daniel Stölzner Aug 31 '16 at 7:09
  • You need to create an event receiver to check this kind of integrity. – Juan Pablo Pussacq Laborde Aug 31 '16 at 12:30
  • @DanielStölzner please check my edited version my question. – Mohit Sikhwal Aug 31 '16 at 14:46
  • Check out the answer here: sharepoint.stackexchange.com/questions/128677/… – Erin L Aug 31 '16 at 14:57
  • i would suggest to have both CSR and event receiver in place for validation, as CSR can still be fooled if the user intends. – bkk Sep 2 '16 at 10:24
1

I have resolve this issue by using Rest API and first we get the data from list and then we have will use that data on the insert and edit form where inserted data is correct or not.

Note: WBS is lookup column

UserName is person and group column

/_api/web/lists/getbytitle('ListName')/Items?"+"$select=WBS/Title,UserName/Title"+"&$expand=WBS,UserName
0

On click of Save button , you need to insert PreSaveAction function. In this function you can check for similar combination of column values. if similar combination found, return false. If not, then return true and allow the item to be saved. More information on PreSaveAction() - here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.