Sunday, June 28, 2009

InfoPath SharePoint: Submit InfoPath form to SharePoint List or Library using Content Type

The following article demonstrates how to integrate an InfoPath form with a SharePoint form library, using a centralised template stored in a SharePoint document library and linked to a site Content Type. The form is set up to submit to a SharePoint form library

Overview:


  1. Set up SharePoint libraries
  2. Design the form template
  3. Publish form template to SharePoint Content Type
  4. Configure the form's primary data connection to submit to the SharePoint library
  5. Secondary Data Connections to receive or submit data to a SharePoint list
Setting up SharePoint to store the Form template and receive Submitted forms:
If InfoPath Form services are available on your SharePoint server, you have the option to store the form template using Central Administration's managed templates list.










To make the form available using this method it must uploaded to the Managed Templates List, the activated for the required site collection.

In this example I publish the form template to a Content Type, saving the template to the "Form Templates" document library in SharePoint. The content type can then be added to a Forms library or Document Library in SharePoint. When the "New" button is clicked on the SharePoint Document Library, a blank InfoPath form will open (in InfoPath, or the browser depending on form, SharePoint and client settings).


  • Create a Document Library to store the form templates. This can be a standard document library. Users of the form template only require read access to the form template to be able to fill out and submit a form. Restricting users acccess to "Read-Only" on the document library containing the form template will prevent any unauthorised access or modifications to the form template.
  • Note: Standard Version control and approval workflows can be set up to help manage form templates in this library.
  • Create a Form Library to store submitted forms and meta data. Use the standard Forms Library.
Design the Form

  • Open InfoPath and Design a Blank Form Template













  • From the Controls toolbar, add 2 text boxes to the form.
  • Right click on the first text box after and select "Text box properties" -> set the field name to "Description_1".
  • Repeat for the second text box, set the field name to "Description_2"

Set up the Primary Data Connection to submit to SharePoint



  • From the Tools menu, select "Submit Options..."
  • Check "Allow users to submit this form"
  • Select "SharePoint Document Library" from the drop-down list
  • Press "Add..." to set up the Primary Data connection
  • Enter the url of the form library created in the second step.
  • Press "Next"
  • Press "Finish"
  • Press "Ok" to close the Submit Option dialog.

Publish the form template to a SharePoint Content Type



  • From the file menu, select "Publish...", you will be prompted to save the form template locally if you have not done so. You are required to do this to be able to publish the form template to SharePoint.
  • Select "To a SharePoint server With or Without InfoPath Form Services" when asked where to publish the form template.






  • Enter the URL of your SharePoint Server, Example "http://SharePointServer/"





  • Select the publish method: "Site Content Type"
Publish Methods for InfoPath form Templates:
-Document Library: The template will be stored and set as the new item template for the specified document library.

- Site Content Type: You will be prompted for the location to store the form template as well as details of the Content type the template is being published to. Publishing a to a content type allows the template to be used in multiple document libraries.

- Administrator Approved Form Template: Allow the template to be published and made available using the Central Administration Managed Templates List.

In this example I will be publishing the form template to a site content type.



  • Select "Create a new Content Type"







  • Enter a name for the content type






  • When asked to specify a location for the form template, enter the URL of the library created in the first step, press Next.


  • Press "Add..", and select the "Description_1" field from the list


  • Repeat for the second field


  • Press "Next"


  • Press "Ok" to close

Add and Set the Content Type as the Form Library's Default

  • Using the browser, navigate to the SharePoint Form library created in the second step.
  • From the "Settings" dropdown menu for the library, select "Forms Library Settings"


  • Under the General Setting heading, click "Advanced Settings"
  • Select "Yes" to Allow management of content types


  • Press OK
  • Under the Content Types section of the Library Settings page, select "Add from existing site content types"
  • Add the newly created content type from the form library, press OK


  • You can either remove the default "Document" content type from the library or set the new content type as the default to allow a blank form to be opened in a browser or InfoPath when the "New" button is pressed on the form library.

When a new form is submitted, it will be submitted to the specified SharePoint form library, with data from the fields in the InfoPath form being mapped to Columns in the library.


Related Articles (SharePoint InfoPath Forms):

InfoPath - Update Existing SharePoint List Item Programmatically Using CAML
How to programmatically update an existing SharePoint list item from an InfoPath form using a CAML query and the lists web service of the SharePoint Site.

Integrate InfoPath Form with SharePoint Workflow
How to integrate InfoPath forms with workflow in SharePoint to give greater control over the functionality and user interface.When an InfoPath form is set up to submit to a SharePoint library, fields in the form can be mapped to columns/fields in the SharePoint library, or a content type which is associated with a document library.


InfoPath Form Content Type & Template Version management
How to manage updated versions of InfoPath form templates when used as Site Content Type.The following article demonstrates how to ensure that an InfoPath form created from an older version of the form template continue to load from the template version which they were created from, while any new form submitted to the library will always use the latest version of the form template.

Thursday, June 18, 2009

Access Denied when trying to upload multiple files to a SharePoint Library

Problem: Access Denied page when uploading files using SharePoint's multiple file upload interface. No details are displayed when the upload fails except the Access Denied page.


In my case, this was not related to permission on the site or document library as the Access Denied page suggests. After uploading one of the files using the single file upload interface, an illegal character message displayed. Once the illegal character was removed, bother the single and multiple file upload interfaces were able to upload the file(s) successfully. For more information about illegal/unsupported characters in SharePoint document libraries see Illegal Characters in SharePoint Document Libraries.


If a large number of files are being uploaded or migrated into SharePoint, there may be many with filenames containing illegal characters. File rename utilities allow conditional renaming of files to remove or replace characters and strings. See Bulk File Rename files to remove or replace illegal characters - allow upload/migration to SharePoint Document Library.

Illegal Characters in SharePoint Document Libraries

The following characters are unsupported / illegal in SharePoint document libraries:

& " : * ? <> # {} % ~ / \ Tab

If the file name of a document contains any of the characters above, a message will be displayed noting SharePoint's illegal characters. If using the multiple upload interface, the response will be an Access Denied page. See
Access Denied when trying to upload multiple files to a SharePoint Library.

For details about bulk file renaming if a large number of files and documents contain illegal characters, see
Bulk File Rename files to remove or replace illegal characters - allow upload/migration to SharePoint Document Library.

Bulk File Rename files to remove or replace illegal characters - allow upload/migration to SharePoint Document Library

SharePoint document libraries can not store files if illegal characters exist in the file name (Illegal Characters in SharePoint (MOSS 2007) ). Migrating/uploading a large number of documents and files to a SharePoint document library can become tedious if you have to rename each file containing illegal characters each time the copy fails (or delayed write error).

To save a time and effort when migrating a large number of files, freeware bulk file renaming utilities are available which allow conditional renaming of files in a directory any sub directories.

The software I used to bulk rename files to remove unsupported characters prior to migrating to SharePoint was the PFrank File Renamer, written by Peter Frankenberger. PFrank allows a series of conditions and rename actions to be performed on each file in a specified directory and any sub directories to remove or replace characters or strings from filenames. The most common is the "&" (ampersand) character, which I replaced with a space then "and" and another space. I then created a condition to replace any remaining double spaces before and after the word "and".

Once all files have been processed by the file rename utility, any illegal characters will be replaced or removed to allow a successful migration into a SharePoint document library.

When using SharePoint's Multiple File Upload interface, file names don't seem to be validated prior to the upload. If any file has an illegal character in the file name is an Access Denied page. See Access Denied when trying to upload multiple files to a SharePoint Library for more information.