SPRequireUnique not loading the ErrMsg

Oct 29, 2013 at 9:02 PM
I've been able to get ArrangeChoices and several other pieces from this to work but for some reason I can't get this one to do anything.

Background
SharePoint 2010
SharePoint Designer 2010
Scripts placed directly below this line
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script language="javascript" type="text/javascript" src=".../SiteAssets/Scripts/jquery-1.8.3.min.js"></script>
<script language="javascript" type="text/javascript" src=".../SiteAssets/Scripts/jquery.SPServices-0.7.2.min.js"></script>

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $().SPServices.SPRequireUnique({    
            columnStaticName: "My_Number",
            duplicateAction: 1,
            ignoreCase: "true",
            initMsg: "This value must be unique.",
            initMsgCSSClass: "ms-vb",
            errMsg: "This value is not unique.",
            errMsgCSSClass: "ms-formvalidation"
        });
    });
</script>
"My_Number" is set prior to the title on the userform. I actually establish the Title field by a concatenation from multiple values from the form via a workflow process.

The initmsg shows up, but when I type in a number that currently exists, nothing happens...even when I switch to the next field, still nothing. Even post Save, the errMsg still doesn't show up.

The column is set to only allow unique values, it is a number field...so would the fact the numbers are stored with commas effect this? if so, how can I address?

Any help would be appreciated!

Thanks team.
Kep
Oct 30, 2013 at 8:32 AM
I too have been having problems getting to grips with this. Don't have a solution yet, but you might wish to following this thread.

Simon
Oct 30, 2013 at 12:34 PM
Sorry Marc, I just reread the front page for this feature and see its only for text fields. Super frustrated now for not reading prior to asking. Any suggestions on a workaround when needing to use the unique feature with numbers?
Coordinator
Oct 30, 2013 at 4:05 PM
Kep:

My only suggestion would be to clone the function and adapt it for your own needs. Alternatively, depending on how you are using the number, you could switch to a text column.

M.
Oct 30, 2013 at 6:53 PM
Thanks Marc,

I will give that a try. I've never done something like that before, but this should be a good task to learn on I suppose.

In the meantime, anyone else that might be having the same issues, what I did is took my single line of text column and then placed a column validation on it with the folllowing.

=IF(AND(LEN(Title)=9,ISNUMBER(Title+0)),TRUE,FALSE)

This will require it to be 9 digits in length and verify it's actually a number. Granted this won't run until Save is clicked, but it's better than nothing for a quick fix.
Coordinator
Oct 30, 2013 at 7:06 PM
Edited Oct 30, 2013 at 7:10 PM
Using jQuery, you can also add validation on the blur event for the text column. Something like this:
$("[title='Title']").blur(function() {

  var thisValue = $(this).val();
  // Add your validation, an alert, etc.

});
You can also put the validation in the PreSaveAction so that the postback doesn't happen unless it passes.

M.
Oct 30, 2013 at 10:12 PM
Edited Oct 30, 2013 at 11:53 PM
Thanks for that.

I'm having issues with saving my files now. The userform just refreshes back to where it was when I click Save.

Bear in mind that I'm using the Title field, however, I have changed the name of it. Am I missing a piece here?

The initial message is loading fine...what could be the issue with the save?
<script language="javascript" type="text/javascript" src=".../Scripts/jquery-1.8.3.min.js"></script>
<script language="javascript" type="text/javascript" src=".../Scripts/jquery.SPServices-0.7.2.min.js"></script>
<script language="javascript" type="text/javascript">
  $(document).ready(function() {
        $().SPServices.SPRequireUnique({    
          columnStaticName: "Title",
          duplicateAction: 1,
          ignoreCase: true,
          initMsg: "Please enter a 9 digit number.",
          initMsgCSSClass: "ms-vb",
          errMsg: "This number has already been entered.",
          errMsgCSSClass: "ms-formvalidation",  showDupes: false,  completefunc: null
        });
  });
</script>
<td width="190px" valign="top" class="ms-formlabel"><span id="part2"><SharePoint:FieldDescription runat="server" id="FieldDescription1" FieldName="Title" ControlMode="New" /></span></td>
<td width="400px" valign="top" class="ms-formbody">
    <xsl:comment>FieldName=&quot;Title&quot;</xsl:comment>
    <SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>                           
</td>
EDIT:
I discovered that a column validation that was previously set was the actual culprit because I didn't remove it from the previous column as well.
Oct 31, 2013 at 2:31 AM
Edited Oct 31, 2013 at 2:54 AM
BACK AGAIN.

I've got everything working now, however, I'm experiencing crazy latency after completing the field and clicking on the next item. just timed at 15 seconds on one process (5835 items, indexed column) and another 43 seconds (16,000 items indexed unique column). I'm also using 24 calls for ArrangeChoices in the same set of code. Is there something I did wrong that's causing me to lock up for so long or is pinging the database just going to take time?
<script language="javascript" type="text/javascript" src=".../Scripts/jquery-1.8.3.min.js"></script>
<script language="javascript" type="text/javascript" src=".../Scripts/jquery.SPServices-0.7.2.min.js"></script>
<script language="javascript" type="text/javascript">
  $(document).ready(function() {
    $().SPServices.SPRequireUnique({    
      columnStaticName: "Title",
      duplicateAction: 1,
      ignoreCase: true,
      initMsg: "Please enter a 9 digit loan number.",
      initMsgCSSClass: "ms-vb",
      errMsg: "This loan number has already been reviewed.",
      errMsgCSSClass: "ms-formvalidation",  showDupes: false,  completefunc: null
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q01",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q02",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q03",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q04",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q05",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q06",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q07",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q08",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q09",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q10",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q11",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q12",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q13",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q14",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q15",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q16",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q17",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q18",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q19",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q20",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Q21",
      perRow: 3
    });
    $().SPServices.SPArrangeChoices({
      columnName: "Complete",
      perRow: 3
    });
  });
</script>
I've also tried this method with no luck as well.
    $().SPServices({
      operation: "GetList",
      listName: "{My List}",
      completefunc: function(xData, Status) {
          $(xData.responseXML).find("Fields>Field").each(function() {
        var $node = $(this);
            var type = $node.attr("Type"); 
            var dispName = $node.attr("DisplayName");
       if(type=="Choice"){
         $().SPServices.SPArrangeChoices({
        columnName: dispName,
        perRow: 3
            });
         }
         });
       }
    });
any advice is appreciated.
Oct 31, 2013 at 2:43 PM
After consideration, I've place a paragraph below the data field letting the user know it will take at least 60 seconds for the userform to unlock. If the user tries clicking multiple times, the page locks.

My question is this - How can I load a "Search Successful" message?
Coordinator
Oct 31, 2013 at 3:08 PM
You're doing a lot when the page loads. If you pare it down, I would assume the page comes back more quickly, right?

M.