Dynamic SharePoint List Submit with Content Types - Jo-Anne Alfafara

InfoPath Dev

Jo-Anne Alfafara

Dynamic SharePoint List Submit with Content Types


You have an InfoPath form, which you want to publish once and then reuse as a template in multiple SharePoint form libraries across any number of SharePoint sub sites. Sure, content types will let you do that. But what if you want data from the content type to a SharePoint List and XML to a SharePoint Library in one fell swoop? InfoPath and SharePoint won’t do this for you, but qRules can.



To follow the steps, you need to:

1. Create an InfoPath form template, injected with qRules v3.1. We will use a sample InfoPath form template that contains the following fields:

2. Create a SharePoint Library where we will open the content type from (this tutorial uses ProjectLibrary).

3. Create two SharePoint lists. One for form list submission and another to store the list GUID and site. This tutorial uses:

a. Project List – the form will submit data to this list.

b. Master List – Master List is a SharePoint list that all users have access to. It contains two columns – one  for ListGUID and one for Site (which is the library URL). When a new project is set up, the master list needs   to have an entry added with the ListGUID of the SharePoint list we will be submitting to, and the URL of the   form library the form will submit to.

NOTE: To know the list GUID, click Settings > List Settings. You’ll see a URL that looks like this: http://<SharePointSite_layouts/listedit.aspx?List=%7B88D72FCD%2D925C%2D4BF6%2D8DDE%2D57314D139292%7D. The List GUID is in red, but we need to decode it to obtain the GUID. You can use an online tool such as http://meyerweb.com/eric/tools/dencoder/ to obtain the GUID, which in this case is {88d72fcd-925c-4bf6-8dde-57314d139292}.

Go ahead and add the Site URL of the SharePoint library you created in step 2 (make sure to omit /Forms/AllItems.aspx and enter the URL in lowercase) and the list GUID of the SharePoint list created in step (3-a) to the master list.


1. Go to Start > All Programs > Qdabra > Tools > qRules > qRules Mapping Tool.

2. This will launch the InfoPath to SharePoint List Tool. When the form is opened, click on Define Mapping.

3. In the Source XSN field, attach your InfoPath form template (XSN).

4. Enter the root SharePoint site in the Target SharePoint Site URL field, e.g. http://SharePointSite

5. Click on the Get SharePoint Lists button.

6. In the SharePoint Lists dropdown, select the list you wish to submit items to, in this sample, “ProjectList”.

7. Click on the Extract Schemas button.

8. Since we’re using a repeating group in our form, we will have to check the box “Data is from repeating group” in the Mapping Definition section.

9. Click on the icon to display the Schema Tree task pane and select the repeating group for your data, which in this case is my:myFields/my:Projects/my:ProjectDetails.

10. Click on the icon in each Form Field row to select the fields from the Schema Tree task pane, and then select the corresponding SharePoint Column to map the fields to. You can also indicate if any of the fields you wish to submit should be treated as Rich Text.

11. When done mapping, click on the Save As qRules Mapping button.

12. Save the mapping as an XML file in your local drive. In this example, we will leave the default name as mapping.xml, although we can use any filename.

13. Once done, close the tool and open the form template in InfoPath Design mode.

14. Go to Data > Data Connections and add a receive data connection.

15. Select XML document as the source of your data and browse to the mapping.xml file that’s been saved in Step 11.

16. Leave the default to include the data as a resource file in the form template and allow automatic retrieve on form open. For simplicity, we will call this data connection “mapping”.


I. Add the data connection to submit to your SharePoint Library

1. Go to Data > Data Connections > Add > Create a new connection to submit data > To a document library on a SharePoint site.

2. Enter the URL to your form library, such as:

3. In the sample, we have added the formula concat("Project Form - ", now()) as the file name.

4. Click Next and name the data connection ShPLib.

II. Add the data connection to receive data from your master list

1. Go to Data > Data Connections > Add > Create a new connection to receive data > SharePoint Library or list.

2. Enter the URL to your SharePoint and select the master list.

3. Select the ListGUID and Site columns.

4. Name the data connection MasterList and select check box for loading data on open.

III. Add the data connection to SharePoint Lists Web Service UpdateListItems

1. Add another data connection that submits data to a Web Service since SharePoint uses a web service for the list methods. The URL should be: http://SharePointSite/_vti_bin/lists.asmx where <SharePointSite> is the root site for the SharePoint list.

2. In the list of operations, select UpdateListItems.

3. For the listName parameter, select the ListCollection node from the mapping secondary data source:

4. For the updates parameter, select the Batch group node:

5. Select to include the updates parameter as an XML subtree, including selected element:

6. Name this data connection ShPSubmit, although, like the mapping connection, you may use whatever name you like. Just be certain to use the same name in the qRules command, including the same case (i.e., if the data connection is “MySpecialMappingFile” you won’t want to use “mYsPeciaLmaPPingfIlE” for the /mapping parameter).

IV. Add a receive data connection to the list using owssvr.dll

1. Go to Data > Data Connections > Add > Create a new connection to receive data > XML document.

2. Enter the link to owssvr.dll of the SharePoint list. An owssvr.dll link is in the following format:

You need to change <serverName> to the name of your server. Change the GUID in the curly braces to the GUID to your list. If you want to test the link in the browser to see if XML is returned from your list, you can.

For SharePoint 2007, you may need to remove &NOREDIRECT=TRUE for the XML to render.

Select the option to access the data from the specified location:

3. Name the data connection owssvr, and deselect the checkbox for loading the data on open:


Get the library and site input parameters and store them in the main data source of the form

1. Add two new fields in the main data source – Library and Site:

2. Drag the QdabraRules node in the view. While you probably won’t want this showing on your final template, it is helpful when you are working on a form with qRules, as you will be able to see any error messages.

3. Double click on the Finished Loading check box. We’re going to add four rules in this field:

4. Click Manage Rules to open the rules task pane.

Rule 1: Get Input Parameters and set Library and Site

This rule will get the values for the input parameters we will set up to pass in later when we modify the “New” button.

1. Click New > Action. Name the first rule Get Input Params and set Library and Site.

2. Add the following conditions:

finishedLoading (QdabraRules data source) is equal to TRUE and
Library (main data source) is blank and
Site (main data source) is blank

3. In this rule, we’re going to have 4 actions to set a field’s value.

a. Set the Command (QdabraRules data source) field’s value to GetInputParameter /key=library.

b. Set the Library (main data source) field’s value to the Result node from QdabraRules data source.

c. Set the Command (QdabraRules data source) field’s value to GetInputParameter /key=shpsite.

d. Set the Site (main data source) field’s value to the Result node from QdabraRules data source.

Final rule should look like:

Rule 2: Change Submit URL

1. Click New > Action. Name the second rule Change Submit URL.

2. Add the following conditions:

finishedLoading (QdabraRules data source) is equal to TRUE and
Library (main data source) is not blank and
Site (main data source) is not blank

3. Set the Command (QdabraRules data source) field’s value to concat("ChangeSubmitUrl /submit=ShPLib /url=", Site, "/", Library).

Rule 3: Set List Collection and Site

1. Click New > Action. Name the third rule Set ListCollection and Site.

2. Add the following conditions:

finishedLoading (QdabraRules data source) is equal to TRUE and
Library (main data source) is not blank and
Site (main data source) is not blank

3. Set the ListCollection field’s value to the formula @ListGUID[@Site = concat(Site, "/", Library)]


  • ListCollection (mapping data source)
  • @ListGUID (master list data source)
  • @Site (master list data source)
  • Library (main data source)
  • Site (main data source)

Rule 4: Refresh SharePoint List Items

1. Click New > Action. Name the fourth rule Refresh SharePoint List Items.

2. Add the following conditions:

finishedLoading (QdabraRules data source) is equal to TRUE and
Library (main data source) is not blank and
Site (main data source) is not blank

3. Set the Command (QdabraRules data source) field’s value to the formula RefreshSharePointListItems /dsname=owssvr /id=my:Id /mapping=mapping /mode=Update.

4. Close the rules task pane for the finished loading field.

5. RefreshSharePointListItems requires an attribute called qRulesLastModified to be added to whatever field you are using for the /id parameter in your SubmitToSharePoint list command. Right click on the field and add a string attribute called qRulesLastModified. When items are submitted to a SharePoint list via the SubmitToSharePointList command, this attribute will be populated with the date and time of the submit. When the RefreshSharePointListItems command is run, that date and time will be compared to the Modified field from the SharePoint list to determine whether the item should be updated.


1. Click Data > Submit Options. Check to allow users to submit the form and select option to perform custom action using Rules. Click OK.

2. Go to Data > Form Submit.

3. We are going to add two submit rules: (1) Submit to SharePoint list and (2) Submit to the SharePoint library where the form was opened from.

4. Click New > Action. Name the first rule Submit To ShP List.

5. Add a new action that set’s a fields value.

6. Set the value of the QdabraRule’s Command field to SubmitToSharePointList /submit=ShPSubmit /mapping=mapping /id=my:Id.


  • /submit – name of the Submit connection you set up to your SharePoint List
  • /mapping – name of the Receive connection you set up to your mapping.xml file
  • /id - the XPath to the field you want to use for the returned Id of your new SharePoint List item after your data is submitted. If your form data is repeating, you want to use the relative XPath (just the bit after the repeating group, i.e. instead of my:myFields/my:repeatingGroup/my:id, you would use my:id). If your form data is NOT repeating, use the full XPath.

7. Create another rule and name it Submit To SharePoint Library.

8. Add the conditions:

Library is not blank and
Site is not blank

9. Add an action to submit data using the submit data connection you created for your SharePoint library.

10. Once all the rules have been set, let’s drag some fields to the view.

11. Drag the repeating table that contains the nodes that we mapped to the SharePoint list:

12. Drag the fields: SharePointListURL, ListCollection, Site and Library to the view. We’re placing it in the view just to see their values when we test the form.

13. Save the changes to your form.


1. In InfoPath, click File > Publish > SharePoint Server.

2. Enter the URL to your SharePoint server. Click Next.

3. In the next window, select Site Content Type (advanced).

4. Select option to create a new content type.

5. Enter a name for your content type. Click Next.

6. When specifying the location and file name of the form template, enter http://<SharePoint Server>/FormServerTemplates/<ContentTypeName>.xsn. Click Next.

7. Select the fields to promote. Click Next and then Publish.

8. Go to SharePoint and open your SharePoint Library.

9. Click Settings > Form Library Settings.

10. Click Advanced Settings. Select “Yes” option to allow management of content types. Click OK.

11. Under Content Types section, click Add from existing site content types.

12. Select the content type you published in step 7. Click the "Add" (>) button, and then click OK.

13. Back in the form library settings, click Change new button order and default content type.

14. Uncheck the check box next to the Form content type and click OK.


1. Launch SharePoint Designer 2007 or 2010, depending on your version of SharePoint.

2. Click Open Site and enter the URL to your SharePoint library.

3. Once it’s finished loading, right click the library web part and select Convert to XSLT data view.

4. Click on the code tab underneath.

5. You’ll see that the code is now converted to XSLT. Put the cursor on top of the code, press CTRL+F and find “NewMenu”.

6. Highlight it and replace with the following lines of code:

<xsl:variable name="library"><xsl:value-of select="substring-before(substring-after($PageUrl, concat($HttpVDir, '/')), '/Forms/')"/></xsl:variable>

<td style="padding-right:10px; padding-left:10px" onMouseOver="this.className='highlight'" onmouseout="this.className='normal'">

<a href="http://<SharePointServer>/FormServerTemplates/<ContentTypeName>.xsn?shpsite={$HttpVDir}&amp;library={$library}">New</a></td>

7. Click Save to save changes to the site.

OPTIONAL: Edit the New link to mimic a button

Since it’s just a link, not a button, it isn’t highlighting on hover like a “real” new button. You can add code to prettify it and mimic the orange highlighting on hovering over the New button in SharePoint.

1. Go back to the SharePoint Designer, if your library web part is still open, click the code tab.

2. Find <style type="text/css">:

3. Insert a new link after the closing braces for padding: Opx; and add the following code:

td.highlight { background-color: orange }
td.normal {background-color:transparent }

4. Save changes to the site.


1. Refresh your SharePoint library and click on New.

2. Click Open when prompted to open the content type. You’ll see that the form opens with the correct parameters:

3. Enter some data in the repeating fields (leave the Id blank) and click Submit button from the menu.

4. Verify that your form is submitted to the SharePoint library and SharePoint List:

5. Modify the list item. Make some changes and then click OK.

6. Open the XML from the SharePoint library and verify that it is also updated with the changes in the list item.


Now that we have a content type as our form template, we can reuse it in another SharePoint library and list in the same site or even on a different sub site.

1. Create your second SharePoint library and list:

NOTE: The easiest way to create your second list and avoid mapping issues would be to save the list as a template, then create your new list off it.

In SharePoint, click Create and under Custom List, you’ll see your template:

Below I have created my second project list out of a template. The columns are automatically copied so I don’t have to worry recreating them:


2. Add both the library and list to your “master” list. We’re adding the GUID of the SharePoint list to the ListGUID column, and the SharePoint Library URL to the Site column (omit the /Forms/AllItems.aspx and then make sure that the URL is in lowercase).

3. Go to the form library settings of your SharePoint Library, and add the content type. Remember that we already went over these steps using our first library. You may go back and review how we added the content type.

4. Modify the All Items view in the SharePoint library to use a hyperlink in place of the new button using SharePoint Designer. And then, edit the link to mimic the “new” button. You may just copy the code that you previously added to your first library.

5. Now refresh your SharePoint library, add and edit items as you’ve done previously.

See how the form knows where to submit list items and XML! J

Another option is to save your sub site as a template – then you can easily create new sub sites that have the same library and list, with the “New” button already set up. All you’d need to do is add the library and list to your master list!



Conny said:

Where nice description. I have tried to follow it, but get an error from the Rule "Get Input Params and set Library and Site" on FinishedLoading field: "The requested key shpsite was not specified in the input parameters". What have I done wrong?

May 5, 2011 6:32 AM

Patrick Halstead said:

Hi Conny,

Jo-Anne wrote up some comments the other day for you. I will send these to you today. Thanks for your patience!

May 5, 2011 6:47 AM
Copyright © 2003-2018 Qdabra Software. All rights reserved.
View our Terms of Use.