locked
creating a unique form number in Infopath 2007 using VSTA on submit RRS feed

Answers

  • >I want this number to be the count of the form in the system by getting the count of forms

    If i understand correctly, you need pure object model code to get the count of form in the system then you can increment by 1. You also need to set that new number in your hidden field so you can set it as form name while submitting.

    Use splistitemcollection.count to get total number of form from library:

    http://msdn.microsoft.com/en-IN/library/microsoft.sharepoint.splistitemcollection.count.aspx

    Hope it could help


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Please feel free to unmark answer if does not resolves your problem.

    Monday, May 27, 2013 4:46 AM
    Moderator

All replies

  • Hello,

    Based on your description, You can add one hidden control on the form and use this control as file name on submit connection. Later you can set this control value using code.

    Let us know if you have any doubt


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Please feel free to unmark answer if does not resolves your problem.

    Tuesday, May 14, 2013 7:44 AM
    Moderator
  • Hello,

    I actually don't want to set this field as the file name. What I want to do is to have a new field that will have a serial number of the form so I wanted to know how can I get this unique serial number. I thought of counting items in the current folder that the current item will be submitted to and increase it by 1 but I don't know how?

    Thanks in advance.

    Tuesday, May 14, 2013 7:50 AM
  • Hi,

    I think you can avoid the code here. Based on that link, it is item ID, which gets created in form library once you save the form. This is auto generate by sharepoint itself and increase by 1.

    For you, if you want only this ID as file name then you can follow the instruction as per below link: (no need of code for this ID)

    http://www.bizsupportonline.net/browserforms/autonumber-infopath-form-submitted-sharepoint-library.htm

    If you want to add additional info with file name then concatenate file name with hidden control and this ID

    Let me know if you still have doubt


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Please feel free to unmark answer if does not resolves your problem.

    Tuesday, May 14, 2013 8:06 AM
    Moderator
  • Hi,

    Thanks for your reply.

    I think the ID field won't solve the issue as the ID field doesn't represent the correct count of the form in case some forms has been created as a test and then deleted so I wanted to generate a count and I wanted to apply it using code as I'm aleady submitting the form using code and I think this number should be set on submit to make sure it is unique.

    Thanks.

    Tuesday, May 14, 2013 8:33 AM
  • Ok then use simple C# logic as mention in below link:

    http://stackoverflow.com/questions/2706500/how-to-generate-random-int-number-c

    Or you can also use now() function, which will create unique datetime value with seconds.

    If you also want to allow user update the existing infopath form from library then now() will not work as this will create new unique datetime every time. so follow the first link and saved the unique in form itself while saving so later you can verify whether form is new or existing one.


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Please feel free to unmark answer if does not resolves your problem.

    Tuesday, May 14, 2013 8:40 AM
    Moderator
  • Hi,

    I actually don't want to get a random number, I want this number to be the count of the form in the system by getting the count of forms in the folder that the form will be submitted to and incrementing this count by 1. (I have different folders in the library representing departments) and I want to apply this using VSTA on submit action as I'm already submitting the form using code.

    Thanks

    Sunday, May 26, 2013 7:18 AM
  • >I want this number to be the count of the form in the system by getting the count of forms

    If i understand correctly, you need pure object model code to get the count of form in the system then you can increment by 1. You also need to set that new number in your hidden field so you can set it as form name while submitting.

    Use splistitemcollection.count to get total number of form from library:

    http://msdn.microsoft.com/en-IN/library/microsoft.sharepoint.splistitemcollection.count.aspx

    Hope it could help


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Please feel free to unmark answer if does not resolves your problem.

    Monday, May 27, 2013 4:46 AM
    Moderator