How To Change An InfoPath View With K2 Blackpearl

Download Code

A classic K2 Workflow goes like this:

An HR Department wants to automate their Leave Request Process.  It is currently a paper based, manual endeavor which has led to some frustrating situations.  They have been told that hosting this process in K2 will alleviate many of their issues. 

In addition to simply building the workflow in K2, the HR Department wants entire submission stored in a SharePoint Form Library for future use.  So, how do we do that?

Firstly, lets assume that this is what the workflow looks like:

Workflow Diagram

Now let’s say that the requirement is to store the request in some “Approved” library if HR approves and “Rejected” if they reject.  Here’s how to do that.

1  Create your form libraries.  I named mine “Approved Leave Requests” and “Rejected Leave Requests” respectively.

2  Create two new views in the form.  The first view shows the data of an approved form, the other for the rejected.

Approved:

Approved Form

  Rejected:

Rejected Form

  3  Use the SharePoint Documents event inside the workflow to create a new document in each of the libraries.

Step 1:  On event name/action step, select to Upload from a K2 field.

SharePoint Documents Step 1

Step 2:  Drag the root node of the InfoPath XML into the input field marked as “K2 Field” 

SharePoint Documents Step 2

Step 3:  Choose the appropriate site, library, and content type (if necessary) for this upload.  For the document name, I’m using the process folio.  You can use whatever you want as long as you don’t forget to type “.xml” after it.

Document Event Step 3

4  Set the view of the InfoPath document, before you upload it.  Use the Data event to accomplish this.

Step 1:  Select Transfer Data

Data Event Step 1

Step 2:  Set the “DocumentView” field to “Leave Request Approved” and “Leave Request Rejected” respectively.

Data Event Step 2

And that’s it.  You’ll see that when the document is created, and viewed, the Approved or Rejected view will be shown accordingly.