Setting a serial number to the current infopath form on SharePoint form library RRS feed

  • Question

  • Hi,

    I would like to set a field in infopath 2007 form template to represent the serial number of the form in the form library that it will be created in in SharePoint 2007. I want this field to have certain format where it will look like: User dept/year/number of the form for this dept in this year. In my form library, I have folders that represents depts and in each folder there are folders to represent years. I could get the user dept and I submit the form directly to the corresponding folder and I thought to get the count of items in the required folder and increment it by one so that this number will represent the number of the Memo but I wanted to do this using whether web services or info path functions as I don't have access to use object model but I couldn't do that, all what I could do was to get the count of items in the root folder but couldn't get the count of items in subfolders and this the post where I was asking about this issue and the code that I tried to use:


    I also thought of some issues that may happen even if I got the count of items in subfolders which is that if two users were filling a form at the same time both users will have the same number and if a form was deleted so a new form will have the number of an existing form in the library as the total count of documents in the folder will decrease so I wanted to knwo how can I get this count and at the same time make sure that it's unique.

    Thanks in advance.

    Tuesday, September 13, 2011 1:42 PM


  • Hi Marwa,

    I don't know of a way to count the number of items within a folder.  What I would do is add Department field from your form as a promoted field.  Then add an on-open rule to your form to query the sharepoint library. In this rule you'll first need to get the department of the employee filling out the form and set the department field.  Then set the department QUERY field of the sharepoint library datasource to the department field in the main datasource of your form.  Then add an action to query that secondary datasource to the sharepoint library.  Now, you can count the items and generate your ID. 

    Once you set all of the fields and set the serial number add an action to submit the form to the library (in the on-open rules) - doing this will ensure a unique number.  That way it saves the unique number right away.  I hope that makes sense.  Let me know if you need more detail.

    • Marked as answer by Pengyu Zhao Thursday, September 22, 2011 2:40 AM
    Tuesday, September 13, 2011 2:21 PM