Upgrade InfoPath Forms without Loss of Data

on Thursday, October 29, 2009

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. This may be required when InfoPath forms are being integrated with SharePoint workflow, as the workflow will be set up to function using data from fields in the most recent version of the form template. If the main data source in the InfoPath form template is updated, the SharePoint Workflow may also need to be updated to cater for any field changes, or additional fields which are required by the workflow. Once the Workflow has been updated to work with the most recent form template version, any new forms submitted to the library will open from the new template, which will then start the updated version of the Workflow. Previous forms created from an older template versions will continue to load using the same template version in which the form was created. Any running Workflows will also continue use the workflow version which was current at the time the form was initially submitted.

Submitted forms can be "Relinked" to the current version of the template as long as they are stored in a SharePoint Form Library. If the forms are being submitted to a standard document library, the "Relink Documents" View and functionality will not be available. There are risks involved when relinking forms to the a more recent version, as modifications to the Form's Data Sources or code may result in the xml file created from an older not being able to open if data can't be mapped to fields in the main Data Source.

Be sure to test relinking an older form to the most recent version, by making sure that the form can open, that calculations, validation, rules and code are working as expected and that the form can be submitted successfully.

If you are certain that a form which is linked to an out-dated InfoPath Form template will function properly once "Re-Linked" to the current version, existing forms can be re-linked using the "Relink Documents" view of the SharePoint Form Library containing the submitted forms.

The process for creating, updating and managing incrementing InfoPath Form Template versions in a live environment, while ensuring that functionality in previous versions of the forms template remains is as follows:

1. Create a SharePoint Document library to store InfoPath form templates(Give it a name infopathcontenttypes).
This library will not be used to submit completed forms to. The sole purpose of this document library is to store template versions. This Document Library is not a Form Library and it is a normal Document Library.
- Set permissions on the document library to grant Read-Only access any user who requires access to the form.So the url of the document library will he http://servername/sitename/infopathcontenttypes

2. Create a SharePoint Form Library for completed forms to be submitted to(Give it a name empforms).
- See Submit InfoPath form to SharePoint List or Library using Content Type for details and instructions on how to set up InfoPath Forms to submit to a SharePoint Library by publishing the form as a site Content Type. This relates to steps 2, 3, 4 and 5. So the URL of Form Library will be http://servername/sitename/empforms

3. Configure the InfoPath Form Data Connection to submit to the Form Library created in Step 2.
See reference in Step 2 above for instructions.

4. Publish the Form Template as a Site Content Type.
This will be used as the default Content Type for the Form Library the submitted forms will be stored in. The form template will be published/saved to the Document Library created in Step 1 during the Publish process.
 Important thing to note is following
 1. Select New Content Type
 2. Give it a name emp content type version1
 3. In the template save location window type "http://servername/sitename/infopathcontenttypes/empversion1.xsn"




5. Set the Content Type created in Step 4 as the default Content Type for the Form Library that completed forms are submitted to (Created in Step 2). See reference in Step 2 above for instructions. You just need to change the content type of empforms library to "emp content type version1".Create some documents and submit them.

6. Changing the form template and publishing again You repeat the step 4 but this time instead of version1 you just replace it with version2  and then you set this new version2 content type as the default in empforms library. Make sure that you don't remove version1 content type.


Making Changes/Updates to the InfoPath Form Template once it is already in use.
Once you have all required components created and configured in the above steps, you will be able to make changes to Form Template without effecting previously submitted forms. This is possible as the Form's Content Type has been set as the default for the Form Library containing the forms.

When a user presses the "New" button on the Form Library, the a blank form will load from the most recent version of the form template. Once the form has been submitted, the template which it was created from is added to the forms XML so that it knows exactly which template to load when opening the form. If an update is then made to the Form Template, the submitted form will continue to load from the form template which it was created from unless "Relinked" to the current version.

The key is not to overwrite a previous Form Template with an updated version, but instead use a manual versioning system by adding the version number to the template filename when publishing the updated template. After the form is saved with a new filename, the Content Type is automatically updated to load new forms from the Updated version. As the previous versions of the template still exist in the form template document library, forms which were created from these versions will continue to open properly.

When making changes to an InfoPath Form template stored on a SharePoint site, you will be required to save a copy of the template somewhere else to be edited. An easy way to check if updates made to a form template will break previous forms if the current version is overwritten with the updated version, is by the message display by InfoPath when saving the form. If changes have been made to the Main Data source, a warning will be displayed when the form template is being overwritten if InfoPath detects that Updates make the different versions incompatible with each other. If this message is displayed, it is usually a good idea to save the Update form template with a new filename to ensure the older version is still accessible to forms which were created from it.


Related Articles:

0 comments: