2

I would like to be able to set a unique constraint on two columns to avoid entries like in the 4th record below (1234,B1)

ColumnA       ColumnB
1234          B1
1212          A1
3211          B1
1234          B1

is it possible to achieve this without using any event handler or workflow?

1 Answer 1

2

I don't think there is something OOB for multiple columns. I would suggest to use JavaScript and override PreSaveAction to prevent the save if the combination exists. Something like that :

function PreSaveAction(){
    //get field 1 value
    //get field 2 value
    //perform a query to check if there are items that matches criteria
    if(noresults)
    {
        return true;
    }
    else
    {
        //show custom error message
        return false;
    }
}

*Heads up if you run a REST call as it will run asynchronous and maybe the PreSaveAction will not work as expected. (haven't tested)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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