Skip to main content
Now i try to do K2 process that start with sharepoint event (user insert file to sharepoint with field). then Infopath will be GUI for user , the uploaded file will be attached in Infopath and the field will be Infopath field.

The first step, it 's ok. i have created K2 process by using SharePoint Template.

But the next step, i don't know how to let the process go on to Infopath on sharepoint form library

Please advise , how can i do ? . do i have to coding or it just configuration. I am very new on K2

Thank you in advance

Nuttapon M.
You used the SharePoint Process Wizard and I assume you have created some event that starts a K2.net Process when you take a certain action in SPS. One of the properties was to choose a K2 Process.

So, now you upload a file into maybe Shared Documents and that will kick off a K2.net process.

You should be able to browse to the following file:
C:Program FilesK2.net 2003K2WSSharePointProcessServiceEventsLib.xml

In this EventsLib.xml file you will see the events that must take place when you take action in SPS. You can also have a look at the Event Viewer on the server where you installed the K2.net SPS web service for info, errors etc.

You can then use a Default Activity and use the InfoPath Event wizard to guide you. There are a lot of ways to use and combine the SPS and InfoPath functions/events depending on what you want to achieve.
icon-quote.gifdavid:

You can then use a Default Activity and use the InfoPath Event wizard to guide you. There are a lot of ways to use and combine the SPS and InfoPath functions/events depending on what you want to achieve.


Yes, i try to use Default Activity and the InfoPath Event wizard . but the problem is i don't have idea how to make my existing process and varible go on on Infopath form. so i think it may do this by coding?

Could you suggest me how to configure infopath event for do this? i just want to bring variable and file from previous activity attach into inforpath form and go on the process

Thank you,
How to correctly update XML Fields in an InfoPath Activity

How to correctly update XML Fields in an InfoPath Activity
Attachment (Pic.zip)

Process XML field refers to ProcessInstance.XMLField( K2InfoPathSchema )
Activity XML field refers to ActivityDestinationInstance.XMLField( K2InfoPathSchema )

When updating field values in XML data fields, the placement of the server event that performs the update will determine whether to use ProcessInstance or ActivityDestinationInstance XML fields for the update.

For server events placed before an InfoPath Client Event (Set Authorisation Level in Figure 1), any XML field value updates should be performed on the Process XML field and not the Activity XML field. The Activity XML field cannot be used here because it is empty prior to the execution of the InfoPath Client Event. If you do, you are most likely to hit an error of the following nature: The root element is missing.

For server events after the InfoPath Client Event (Timestamp Approval), the Activity XML field should be used for updating XML field values. Upon completing the final server event, the implicit Succeeding Rule within the InfoPath Activity will be executed, and it copies values from Activity XML fields to Process XML fields. Consequently, any updates made to Process XML field after the InfoPath Client Event will be overwritten by Activity XML field.
The InfoPath Activity s Succeeding Rule is embedded in the code window and does not register on the GUI view of the rule. Thus, it is not immediately apparent to most K2.net developers that XML field value updates are to be made to Activity XML fields.

Example code in Set Authorisation Level Server Event
The following code will set the value of ManagerDisplayNextAuthSelection based on the value of PurchaseTotal.

Sub Main(ByVal K2 As ServerEventContext)
K2.Synchronous = True

Dim PurchaseTotal As double= CDbl(SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:PurchaseOrder/my:Order/my:OrderPriceTotal"))

If PurchaseTotal > CDbl(K2.StringTable("Level2ApprovalLimit")) Then
K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value = SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:PurchaseOrder/my:Manager/my:ManagerDisplayNextAuthSelection","True")
Else
K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value = SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:PurchaseOrder/my:Manager/my:ManagerDisplayNextAuthSelection","False")
End If

End Sub


Example code in Timestamp Approval Server Event
The following code will set a timestamp into ManagerApprovalDateTime.
Sub Main(ByVal K2 As ServerEventContext)
K2.Synchronous = True

Dim sTimeStamp As String = Now.ToString("MM/dd/yyyy HH:mm:ss tt")
K2.ActivityInstanceDestination.XmlFields("K2InfoPathSchema").Value = SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ActivityInstanceDestination.XmlFields("K2InfoPathSchema").Value,"my:PurchaseOrder/my:Manager/my:ManagerApprovalDateTime",sTimeStamp)

End Sub


Hope this helps.
Thank you for your advice, i will try to adjust it to my project.

Reply