My client currently had an InfoPath form published to a forms library in SharePoint. They wanted some amendments made to the form, including additional fields.
They wanted all the existing forms within the library to have all the new version's amendments.
This was not going to be possible with a normal InfoPath form upgrade.
What I did was:
- Extracted the data from the old form and temporarily stored it.
- Created a new form with the same name and overwrote the existing form.
- Populated the new form with the stored data.
- Using workflow actions:
- I query the list for all items matching the content type version 1 of the InfoPath form.
- I loop through the results of this query:
- using a 'Query XML' action, I retrieve the data from the existing form.
- I create a new item using the 'Create an item' action. I set the name to exactly the same name as the current form item and specify 'Overwrite an existing item'. I store all data retrieved in the 'Query XML' in a temporary field value which I called 'Form XML'. When the new item is created it overwrites the current item preserving it's ID.
- I then kick off a second workflow using the Nintex web service method called StartWorkflowOnListItem. (http://<site>/_vti_bin/nintexworkflow/workflow.asmx). This workflow kicks off on a specific item specified by the list item ID.
- Using multiple 'Query XML' actions I retrieve the data from the temperary field I stored it in.
- Using an 'Update XML' I update the new form with the old data.
I have excluded any business rules I have in my current workflows for the purposes of this blog.
Some of you might be wondering why I used a temperary field to store the data instead of passing the data via the web service method using the associationData tag.
I had issues when passing the data using the a associationData tag. The temperary field was a quick and easy workaround I could implement as this solution was going to be used as a once off to upgrade existing forms.