To generate Sequential Reference ID for infopath forms across sites without using code

 

In one of the projects we got a requirement to generate Sequenctial Reference ID's for all infopath forms across sites and thats too without using Code. It means i have form A in a site A and form is submitted so reference ID of that form should come as  1.  After that

another Form B is submitted ,reference ID for that form should be 2 and so on for all forms across sites. We could take sql server help to achieve that functionality but we had to achieve it without using code.

 

Approach

We created a master list at root level site with just title field in it. Now for every infopath form created in a form library we create a new item in this list using infopath submit connections, and there has to be a unique mapping between each infopath

submitted  form and a item of master list. The title of each item is mapped to one of the field in Infopath Form, so that for every infopath form submitted we can retrieve the corresponding item from master list. The ID of item in master list is taken

as reference ID of infopath form. As ID is always sequential we can take it as reference ID for infopath Form.

 

Steps

 

1) Create a Sample Infopath form. We have just created basic form.

 2) DataConnections

 

 

   a) SharePoint Library Submit:- This is the usual Submit connection used to submit Infopath Form to a form Library. The Field "frmFormName" is used as form Name in Submit Connection as shown Below.

 

Where field "frmName" is configured as below :-

 

b) Data :- This Data connection is recieve data connection(XML File). This XML file is used to pass as paramter in "Web Service Data Connection" which will be described in next point. The content of this XML File is as shown below:-              

<Batch OnError="Continue">
    <Method ID="1" Cmd="New">
        <Field Name='Title'></Field>
    </Method>
</Batch>

 

c) Web Service Submit:- This Dataconnection is WebService Submit Connection. As i described in approach, we need to create item in Master list for each Form. As we don't have direct way to create item in a list using Infopath forms. We are doing it using webservice Connections. Webmethod "UpdateListItems" from "Lists.asmx" webservice is used to  create item in Master List. This Webmethod(UpdateListItems) require two parameters as a input. First is ListName which is provided by "fldListName" of Infopath Form. Second one is Batch XML which is provided by XMl Dataconnection as shown above.

 

            

 

 

 

 This is how Webservice Data Connection is configured. As it is displayedi in Screen shot, UpdateListItems operation take two parameter as input. 1) Name of List in which items needs to be created

2) tns:Updates :- This paramter takes data as XML Format(Which is provided by Secondry Data Connection(Named as Data)). This will contain the values for each field in item. For this Demo we are just passing value of Title Field. Now if you carefully examine the Batch XML which was shown Earlier, Look at this node:-

<Field Name='Title'></Field>

Right now this is empty node i.e. it doesnt contain any value. This XML Node must have to be populated with some value so that item can be created in master list. We will set this value Using Submit Options Rules which will be described later in this section. This value is populated by "frmFormName" field of Infopath Form using Submit Option Rule.

 

d) MasterFormList :- This is Recieve DataConnection which is used to get reference number of Infopath Form once it is submitted. It will take data from "MasterForm" List.

 and seqNo field will take value from this dataconnection using filter of title field as shown below: -

3) Submit Rules

 There are two submit Rules Configured.

1) Rule 1:- (will execute on this condition When "IsSubmitted= N")[The Default value of IsSubmitted is N ]

     Actions

  •    Set Title Field of XML(Secondry Data Connection)

  •    Submit WebService Connection
  •    Submit SharePoint Library Connection
  •    Set IsSubmitted = "Y" (This is used so that this rule will not execute again)

2) Rule 2 (will execute on this condition When "IsSubmitted= Y")

     Actions

  •    Submit SharePoint Library Connection

 

Demo

1)  i opened a new infopath form. Fill it with same value and submitted it.

 

 

So a form is submitted and new entry is created in form library as well as in MasterForm list which is used to store all reference ID's. Notice the title of item in Master list this is mapped to "frmFormname" Field of Infopath Form.

 

Now if i open existing form. it should give me reference ID as "1".