Skip to main content
Hi is there an easy way to move an infopath form from one Sharepoint form library to another once a process is complete?

I get the following error using the Sharepoint Multiple Documents Event

System.Xml.XmlException: The root element is missing.
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadWithCollectTextToken()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at K2Code1459.Main(ServerEventContext& K2)
Hi,

I think the question here is why are you using the multiple document event template to move a single InfoPath document? Is there another reason for this?

You may find that an upload of an InfoPath document is easier to achieve by using the standard sharepoint document event template.

The XML referenced in the multiple document template defines the list of documents that are to be uploaded/downloaded etc. - so that K2 can iterate through the list of them. By referencing your InfoPath document here instead, an error such as that shown in your post would be expected (the XML doesn't include a list of documents, it just includes the content of your infopath document).

I hope that helps.
Carl.
To extend on Carl's post...(and because I haven't seen this trick on the forum and I had just finished typing my reply as Carl posted his reply - deleting all this text just felt wrong 🙂 )

Are you wanting to upload the entire InfoPath document that was used in the process to the new SPS document library? In this case, the easiest way is to use the SharePoint 2003 Document Event template (the single document event, not the multiple documents event) and use the K2InfoPathSchema process XML datafield as the source for the document. Remember that this process XML datafield effectively contains the whole InfoPath document (in other words, the XML that makes up the IP document), so it's all you need to be able to save the InfoPath document to the SPS library.

Remember to append .xml to the filename you are creating so that the file will be opened with InfoPath. Also, by default the InfoPath XML will be switched to whatever the last view of the InfoPath form was, so you may want to use the InfoPath Change View event to switch to a different view before uploading the InfoPath file to SPS.

HTH....
Neil,
I was interested in how to do this also. Your instructions say to use the K2InfoPathSchema process xml datafield. I don't see that datafield. Am I missing something?
the K2InfoPathSchema process xml datafield. I don't see that datafield

two pointers:
1) that XML datafield will only exist if the process is an InfoPath-integrated process. In other words, did you use the InfoPath process template when you initially created the process? The InfoPath process wizard would have automatically created the K2InfoPathSchema XML datafield.

2)K2InfoPathSchema is a Process XML datafield, which will be listed separately form normal process datafields when you're looking at the properties of the process. (Right-click anywhere on a blank part of the process design canvas, select 'Properties' and then select 'XML Fields' in the process properties browser - you should see the K2InfoPathSchema XML datafield listed.

Hi is there an easy way to move an InfoPath form from one Sharepoint form library to another once a process is complete?

If you are not using a InfoPath process where the InfoPath document is saved to a process XML datafield called K2InfoPathSchema, you can use a combination of the following SharePoint document events to retrieve the contents of a specified document, upload these contents to the new document library and finally deleting the old document from the source document library:

1) Use the SharePoint 2003 Document event template and select the 'Get Latest version' option. Create a process or activity string datafield (note: disable auditing for this datafield) and set this datafield as the destination document for the 'Get latest version' action. This will copy the contents of the source document into a process datafield.
2) Use the SharePoint 2003 Document event template and select the 'Upload' option. Use the process string datafield you created in step 1 as the source of the document to upload. This action will take the contents of the old document you saved into a process datafield, and upload these contents into the new document library - effectively creating a copy of the source document in the new document library.
3) use a k2 server event to set the datafield you created in step 1 to a blank value - this is to save on storage space in the K2 log database.
4) Use the SharePoint 2003 Document event template and select the 'Delete' option to delete the source document you used in step 1. This will remove the source document from the source document library.

A couple of notes:

1) This is probably the easiest 'no-code' approach to copy a document from one SharePoint library to another. There are much more efficient ways of doing this of course if you're prepared to dive down into code. You could always manually combine the code generated by the four events into one server event, or you could look into the API's exposed by SharePoint itself.
2) If you do choose to use the event templates as I described, be sure to disable audit trail for the datafield in which you temporarily store the document contents and to clean out the datafield after you've copied the document to the new library. The reason for this is to save storage space in the K2Log database, otherwise that 3MB document you copied will take up 3MB of space in the K2Log database.

Hope this helps!

Reply