Skip to main content
I have a process created using the Sharepoint process template. The process is started when a document is loaded into a document library. I would like to use InfoPath forms for the various document approval stages but the only example that integrates InfoPath and K2 I've seen is where the process is created with the InfoPath template. Obviously I can't create a single process using two different process templates. However, I have added an InfoPath Server event to my process and pointed it to my Sharepoint site.

How can I create the InfoPath form so it's XML is recognized within the process without using the InfoPath process template?

Instead of the InfoPath having it's own XML dataset, can the InfoPath form be configured to use the existing EventDetail and AttachedDocuments XML datasets? If so, how?

Should I, instead, start with the InfoPath process template and add the Sharepoint items manually? If so, how?

Thank you.
I did this recently and unfortunately there is no simple drag and drop way to do this. Basically you have to build the InfoPath XML programmatically.

The easiest way to do it is to create the InfoPath form event. Then create a server event that runs before the InfoPath event. In the server event you dynamically build the InfoPath XML and insert it into the K2InfoPathSchema XMLField. Then in the Succeeding rule (or in another server event after the InfoPath event) make sure you grab the K2InfoPathSchema XMLField and insert the values you want back into your process or activity data.
If you are using K2.net 2003 SP1, there is a new feature that enables you to import Data Fields from another process definition. For Steven's scenario, you could start by creating a SPS Process using the SPS Process Template, and also create an InfoPath process using the InfoPath Process Template. Thereafter, in the SPS process, use the Import function found in the Data Fields dialog, to import the process data fields as well as the XML fields from the InfoPath process. Do note that some data fields are required within the Activity where the InfoPath server event resides, so you should import into the corresponding Activity as required.
icon-quote.gifebobwright:
I did this recently and unfortunately there is no simple drag and drop way to do this. Basically you have to build the InfoPath XML programmatically.


That sounds like a lot of work. Probably, though, you had no choice. K2.Net 2003 SP1 has only recently become available.
icon-quote.gifsamuelkoh:
If you are using K2.net 2003 SP1, there is a new feature that enables you to import Data Fields from another process definition. For Steven's scenario, you could start by creating a SPS Process using the SPS Process Template, and also create an InfoPath process using the InfoPath Process Template. Thereafter, in the SPS process, use the Import function found in the Data Fields dialog, to import the process data fields as well as the XML fields from the InfoPath process. Do note that some data fields are required within the Activity where the InfoPath server event resides, so you should import into the corresponding Activity as required.


Thank you. I'll give this a try.
That helped, but I've still got some problems getting the data from the "Sharepoint" XML to the "InfoPath" XML. I've got a server event in the same activity and just prior to my InfoPath form event that copies the data over. Here's the code:

 Dim strFileURL As String
Dim strStatus As String

K2.Synchronous = True
strFileURL = SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("EventDetail").Value,"EventData/FileFullUrl")
strStatus = K2.ProcessInstance.DataFields("Approval Status").Value.ToString

' Error occurs on the following line of code
K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value = SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:FileFullURL", strFileURL)
K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value = SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:ApprovalStatus", strStatus)


When this process is started, line 5 generates the error "The root element is missing". What's odd is that this same line of code placed in the original InfoPath process (the one from which I imported the XML) runs just fine. It seems there's still something missing that is preventing the code from working properly.
I'd say that your InfoPath xml is empty in the sharepoint process and that's why you're getting the error. You can't SetXMLData if there's no node. The reason this works in the InfoPath process is because K2InfoPathSchema is initialized by the process itself with the data from the form.

You'll have to build the xml structure yourself. One way to do this quickly so that you can start assigning data is by setting the Value of the K2InfoPathSchema XML field equal to it's own MetaData value.
icon-quote.gifebobwright:
I'd say that your InfoPath xml is empty in the sharepoint process and that's why you're getting the error. You can't SetXMLData if there's no node. The reason this works in the InfoPath process is because K2InfoPathSchema is initialized by the process itself with the data from the form.


That sounds plausible... Maybe, I'll dig through the scripts that are generated for the InfoPath form to see if there's some code I can borrow that will instatiate the XML node for me.

Reply