Pages

Thursday, July 26, 2012

How to K2 - SmartObject and InfoPath Integration (part2)

This is the second part of the serie where we focus on how InfoPath and SmartObjects technology can be used together to build eForms that integrate with a K2 workflow.

K2 and InfoPath integration

There a few things that are worth to know when it comes to integrate Info Path forms with a K2 workflow. K2 provides with their products, in particular with K2 Studio and K2 Designer for Visual Studio, very strong integration features with Info Path forms and Smart Objects.
The following is a list of key features of K2 when it comes to Integration with Info Path
  • Single Form per process or multiple forms per process
  • Form Versioning
  • Read/Write access through SmartObjects
  • Automatic Task View Switching
  • Dynamic runtime task actions
  • Code Behind

Let's discuss the features in more detail

Single Form per process or multiple forms per process

The tools provide the user with an InfoPath Integration wizard that allows to select one or more forms that can be used in a process. Once the InfoPath form is connected with the workfow the forms will be deployed automatically with the workflow as well.

 

Form Versioning

I guess every developer who has worked with InfoPath knows, that versioning can be pretty painful and difficult to manage. The advantage with the InfoPath Integration in K2 is that the forms will be automatically versioned for you and deployed along with the process. Every time you deploy a process the form will be redeployed as well. This allows that the form and the workflow are both in sync. In order to use the form versioning feature it is important that every time you have to change the InfoPath form, you have to do it from withing the Workflow Form Template wizard as shown in the above screenshot (Design button). Changes to the form will be automatically saved with the workflow. The form will be automatically deployed as specified (either to a SharePoint Forms library or to a Network Location)

 

Read/Write Access through Smart Objects

One of the really cool features that distinguishes K2 with other workflow platforms are Smart Objects. A common issue and problem with InfoPath is the way it stores its data. InfoPath is simply an XML file which stores the data as a blob in a SharePoint library for example. Applying security to form data is very limited and also the reporting capabilities on form data is difficult.

With using Smart Objects both of these issues can be solved. Smart Objects allow to seperate the data in a form (values). Instead of storing the field values within the form, they are stored in a Smart Object. Information will be loaded at runtime into the form but data is stored in the SmartObject. The Smart Object acts as a data layer to retrieve and store data. It provides the CRUD operations and the properties that represent the info path form.Once the Smart Object exisists it can be integrated with an Info Path form.

Smart Object Creation Wizard in Visual Studio

Automatic task view switching

When desiging an InfoPath form someone usually creates mutliple views. E.g. one initial view to submit a request form and another view for approval. K2 provides a feature to display the correct task form for each workflow action event.



Dynamic runtime task actions

When someone creates a client event (e.g. Approval request) it is possible to define multiple outcome actions. E.g. for an approval request we could define 3 outcomes: Approved, Declined, Request for Change. The outcome actions defined can be connected to an InfoPath action field to dynamically create runtime task actions for a user. As shown in the above screenshot the first part shows the workflow client event with its 3 outcomes (Request Approved, Request Declined, Request Change) In the below picture the actions have been converted into a drop down field in InfoPath.

 

Code Behind

Writing code behind in an InfoPath form is supported and works but I personally would recommend to avoid going down that path in writing code behind as much as possible. When it comes to K2 and InfoPath integration, once you start writing code behind you loose the versioning and synchronisation between the workflow and the form. The InfoPath form has to be deployed manually and is not deployed with the K2 workflow automatically.

 

InfoPath Forms - Pros and Cons

InfoPath forms offer a lot of advantages when it comes to designing web based forms in SharePoint but there are also a few cons that have to be considered before going down the InfoPath way

Pros 

  • No code design
  • Rapid form design
  • Form Versioning
  • Tight integration with SharePoint and Office

Cons

  • Extensibility is limited
  • Data is difficult to report on
  • Data security can be an issue
With the last 2 cons Smart Objects can be used to overcome these issues. K2 also supports and integrates with ASP.NET forms in case Info Path is not the first choice and a lot of customization and code behind is required to develop the form.

 

Best Practices for K2 and InfoPath integration

When developing a K2 - Info Path - Smart Object integrated workflow there a few Best Practices that should be considered and followed to avoid problems right from the beginning.
  • Backup Forms
  • Use InfoPath process wizard to design IP forms
  • Avoid code behind (compicates the deployment and K2 integration/versioning)
  • Convert non-Smart Object secondary data sources to UDCX
  • Unless you are using code behind, let K2 deploy the Info Path form
  • 1 view and 1 task action field per client event
  • exernalize form data (get data from outside of InfoPath, store data outside of Info Path)

The next part of the serie will show a practical example of how to build a leave request workflow

We hope you enjoyed reading this article. If you have questions or further information please leave a comment.


No comments:

Post a Comment