Preventing duplicates in a Sharepoint Form Library - InfoPath Dev
in

InfoPath Dev

Preventing duplicates in a Sharepoint Form Library

Last post 07-09-2009 09:26 PM by djj66. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-09-2009 12:00 AM

    • djj66
    • Not Ranked
    • Joined on 05-26-2009
    • Posts 13

    Preventing duplicates in a Sharepoint Form Library

    Hi everyone,

    I have an InfoPath 2003 form which gets submitted to a Sharepoint Document Library. I need to prevent duplicate entries in the library, and each submission has a DocumentID which should be unique. I have tried querying the Sharepoint Library, but this only queries the default view for a folder, and only returns the list limit (100 unless changed). I can't use the default view, because this only contains "Pending documents" not the full list of documents.

     I'm writing my form code in VBScript (IP 2003) - can anyone advise me the bext way to ensure my Sharepoint document libary does not accept duplicates. If I need code, if anyone can suggest VBScript I could use, that would be much appreciated.

     thanks!

    david

  • 07-09-2009 11:59 AM In reply to

    Re: Preventing duplicates in a Sharepoint Form Library

    Don't use code for this.  Either ensure that each filename is unique using something other than DocumentID or leverage a different view that does show the max current ID:

    Auto-Generating Filenames for InfoPath Forms

    Auto-Numbering InfoPath Forms

  • 07-09-2009 07:07 PM In reply to

    • djj66
    • Not Ranked
    • Joined on 05-26-2009
    • Posts 13

    Re: Preventing duplicates in a Sharepoint Form Library

    Thanks for this, but it doesn't really apply to my situation.

     The number I need to ensure is unique comes from a paper document, so I can't use an "auto-number". The document number on paper IS unique, but I need to protect against a document being mistakenly entered twice. I am also NOT submitting to a database, so I can't use a Primary key field check from the DB. I am submitting to a Sharepoint Form Library so I need something to check if that Document number has been submitted before. At the moment (with IP 2003) if you submit a new document with the same Document ID as a previous one, then either a duplicate is created, or the original is overwritten (neither of these are acceptable)

     The best I've found so far is to check the default view and extend the number of items from 100 to 10,000, but it's still not failsafe.

    Is there anyway to ensure sharepoint folders (or lists) have unique fields - I've seen indexed fields, but not unqiue fields?

    thanks again!

  • 07-09-2009 07:35 PM In reply to

    Re: Preventing duplicates in a Sharepoint Form Library

    I'm not sure what you meant by the database comment, since both of my blogs are referring to SharePoint, but SharePoint _is_ a database.  Why can you not do a field check from the "db," which is just the SharePoint form library?  You can definitely create a data connection to receive data from your form library in order to check if that Document ID already exists.  If it does, then pop up an error saying so and don't let the submit continue.  Sounds really simple to me, but maybe I'm missing something?

    You keep referring to a Document ID, but you make it sound like that is the filename.  This document ID you're talking about comes from the original Word doc, right?  That is not the same thing as the InfoPath filename in the form library unless you are choosing to submit the forms using that Word document ID as the filename.  I would not make that the filename, or at least I would not rely on the filename to do my primary key check.  Create a field in the form that gets promoted to the form library that contains the Document ID.  In your submit button, check to see if the current form's Doc ID is already in the library.  The conditional statement would look like this:

    If Any Occurrence of SharePointList:DocID is equal to ThisForm:DocID, then display message saying whatever.  If Not, then submit.

     

  • 07-09-2009 07:55 PM In reply to

    • djj66
    • Not Ranked
    • Joined on 05-26-2009
    • Posts 13

    Re: Preventing duplicates in a Sharepoint Form Library

    Hi Clayton,

    Yes I'm aware Sharepoint is a DB (based on one, anyway), but there's no way (that I know) to ensure entries in a Sharepoint folder/list are unique. As a fudge/workaround, I am doing a check on the Sharepoint Form library (as a receive data connection in IP), and this works OK, but it relies on the "Default view" in the Sharepoint folder having all the records in that view. It works OK, except that someone might change the default view, without realising it will affect the duplicate check.  (so it's far from ideal as a way of preventing duplicates)

    The document ID I'm referring to is a pre-printed number on the paper forms. It's the only check I have to prevent a form from being entered twice.

    I did find this link http://www.infopathdev.com/blogs/agni/archive/2006/05/15/Query-for-Items-in-SharePoint-Form-Library-Using-GetListItems-Web-Method.aspx which appears to be what I need, except that it's based in IP2007, and I haven't been able to convert the code into VBScript.

     I'm not sure if this helps, I'm happy to clarify anything if necessary. thanks again though!

  • 07-09-2009 08:04 PM In reply to

    Re: Preventing duplicates in a Sharepoint Form Library

    Though still not ideal, you can make a different view that shows nothing but one column and has every record.  Then, get the direct URL to XML version of that view and use it as a data connection.  You do this using this method:

    http://blogs.msdn.com/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx

    Any reason you can't use IP07?  Office 2003 is about to be 2 versions old and is not the most recommended platform for building forms that will be used in the future, since the object model is different from 2007 (and 2010).

  • 07-09-2009 09:26 PM In reply to

    • djj66
    • Not Ranked
    • Joined on 05-26-2009
    • Posts 13

    Re: Preventing duplicates in a Sharepoint Form Library

    Thanks Clayton,

    Thanks for the link, yes this looks like something I can use, the important thing being that is does not have to be the default view.

    Any reason I can't use IP2007?  - well, no good reason :-). The company I'm working with still has IP2003 as standard, with no immediate plans to upgrade. We'll have to upgrade sooner or later, at which time I expect I'll need to redevelop the form.

    Thanks again for your help. regards, david

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.