This project has moved and is read-only. For the latest updates, please go here.

SPRequireUnique CrossList Functionality

Jan 26, 2012 at 2:39 PM

Just wondering if there is an option or someone has implemented modified SPRequireUnique function enabled to work on different lists. What I mean is... I want to check unique value within List B where columnStaticName (input column) is on the List A on the NewForm.aspx. 

Any help will be much appreciated.


Jan 30, 2012 at 12:20 AM

There's nothing specific in SPServices for this, but you can use SPServices as your toolset to accomplish it. You can lookup the values in list B using GetListItems, either as the user types or upon form submission using PreSaveAction.


Jan 30, 2012 at 9:13 AM
<script type="text/javascript">

function PreSaveAction() {  
    var GetListItems = $(document).ready(function() {
    operation: "GetListItems",
    async: false,
    listName: "{95FDDCC5-4B57-4F5B-BD59-F91D486B1375}",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";

<ul id="tasksUL"/> 
    var text1 = getTagFromIdentifierAndTitle("input","TextField","Item Number");  
    if (GetListItems.value == "(text1.value == "")")  
        alert("This Item Number exists. Please input unique Item Number");  
        return false;  
    return true; 

function getTagFromIdentifierAndTitle(tagName, identifier, title) {  
    var len = identifier.length;  
    var tags = document.getElementsByTagName(tagName);  
    for (var i=0; i < tags.length; i++) {  
        var tempString = tags[i].id;  
        if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {  
            return tags[i];  
    return null;  


Hi Marc,

I am not a programmer and don’t know if I am on right way to accomplish this task. I took your advice and try to implement using GetListItems and PreSaveAction but this don’t work for me. Probably my coding is rubbish.

Any idea how to do it?




Jan 30, 2012 at 6:56 PM


In your PreSaveAction, you'll want to get any items which match the value you want to check. Right now, you don't have any filtering; you're just getting all of the values. If you return false from PreSaveAction, the form won't save. You will want to give the user some sort of message, of course, so that they know what they need to fix.