Accessing K2 API via K2 reference event

clock September 1, 2010 17:22 by author steveboldt

There is a way to access the K2 API from the reference event, although I will make the disclaimer that this is not supported in blackpoint. I will go over the steps of calling the GoToActivity method of the API from a reference event within the K2 designer.

Within K2 designer, you will need to drag a reference event onto the workspace. k2referenceevent

 

Configure an event name for the event, and after clicking next, you will come to a screen within the wizard to add a Constructor.

k2referenceevent_addevent

The next wizard you will want to click the "Add Reference” button and browse to “C:\Program Files (x86)\K2 blackpearl\Bin\SourceCode.Workflow.Management.dll” (if using a 64bit server). Select this DLL and add it to the list of available managed process references.

k2referenceevent_addref Click finish and then on the wizard where you select the constructor, expand the nodes as follows:

SourceCode.Workflow.Management
– SourceCode.Workflow.Management 
     – WorkflowManagementServer 

select Constructor(String host, UInt32 port).
k2referenceevent_addeventwms

 

For the configuration properties of the constructor, enter the following:

host: value is the server name of K2
port: value is the port that the K2 server is running on (typically 5555)
k2referenceevent_addeventwms_b

 

Once this constructor has been added, you will be brought back to the main wizard screen for the reference event and now it will allow you to add a Method event.

k2referenceevent_addmethodevent

After you click the add method option, you will need to expand the WorkflowManagementServer node and scroll down and find the method Open()

 

k2referenceevent_open Select Next and leave the default values for the configure properties and click Finish

 

 

 

Once more on the reference event main screen, click Add Method and expand out WorkflowManagementServer and find the method GoToActivity(Int32 procInstID, String activityName) : Boolean

k2referenceevent_goto

After clicking next, you will need to configure the method. The only values you need to worry about populating are the procInstID and activityName.

procInstID – identifies the K2 process ID that you want to perform the GoToActivity method request. This values can be accessed many different ways. For my example, I stored the K2 process ID of my workflow in a SharePoint list and I called this workflow on the update of the list item (using the SharePoint event integration process within K2) and stored the ID in a data field.

activityName – this field refers to the Activity in question that you want to “Go To”. If you reference the correct process ID, you can call an activity in any K2 process as long as you have the activity name correct.

Click Next after configuring these 2 values, leave the connection properties as default (empty) and click Finish
k2referenceevent_gotoconfigure

 

k2referenceevent_finish

At this point, you are done configuring your Reference event and it should look like the screenshot to the left. Click Finish and you are done with the reference to the K2 API. Build and Deploy your process and test it out.

Currently rated 3.2 by 11 people

  • Currently 3.181818/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


K2 Tips & Tricks #2 – Using the InfoPath toolbar Submit button as a task action

clock November 19, 2009 11:29 by author steveboldt

Sometimes, when using K2 blackpoint or K2 blackpearl, you encounter InfoPath forms that you only have one choice in the workflow. For example, you have an InfoPath form that the originator fills out and submits to IT. Then, IT fills out the required information and submits the form to accounting. No decision is made, just filling out the information needed and submitting the form. With the InfoPath client event, you need to specify a task action field to direct the outcome of the process. Usually, the client event wants you to bind to a drop down, but if you already know the outcome, this isn’t necessary.

The solution:

Open up the InfoPath form in design mode from K2. Add a new field to the data source of data type string (ie. TaskActionSubmit). Set the Default value to Submit. Save the form and close it. Once K2 has let you know the form template has been updated, go to your InfoPath client event and below in the Task Action field, select the field you just created.

When you click Next, a popup will ask you if you want to change the drop down configuration. Select NO.

 bind_dropdown

Click Next through the wizard until the Actions screen. Add an action called Submit (the same value you put in the default value field for the node you created in the data source of the InfoPath form). Check the box for generating a line for outcomes. Do the same for the outcomes screen. Then click Finish.

At this point, when you run the form, when the user clicks the submit button of the form, it will use the action field that you bound to direct the workflow.

Currently rated 3.2 by 22 people

  • Currently 3.181818/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


K2 Tips & Tricks #1 – Displaying the correct InfoPath view in the client event

clock November 18, 2009 16:10 by author steveboldt

From my own personal experience and hearing the frustration of others, there are some times when integrating an InfoPath form that it won’t display the correct view on certain activities. Usually, this is a random occurrence and will result in the form displaying the default view instead of the desired one.

Well, now, this problem can be resolved with a very easy fix! More then likely, at one point in the process, you were creating views, and either created, renamed or deleted a view. As a result of this, entries should be either modified in the manifest.xsf of the Form template. However, for some reason, this doesn’t always occur and will cause inconsistencies.

If you are experiencing the problem of the correct view not displaying, more then likely a RULE is not configured properly in the open behavior of the form. To verify this, you can go to the form option and select the Open and Save category from the options and select the Rules button in the Open behavior section. This will give you a list of rules that will fire upon opening of the form. K2 sets these rules based upon your configuring of the InfoPath client event in each activity.  While you have these rules open, copy the template file from the K2 InfoPath Form Template folder and rename it with a .cab extensions. This way, you can extract out the manifest.xsf file locally.  Search for the ruleSet section named "ruleSet_OnLoad” and you will more then likely see a discrepency between the rules displaying in the form options and the ones in the manifest.xsf.

The Fix (K2 blackpearl or K2 blackpoint)

Here are the steps you need to take to resolve the problem:

  • Open up the InfoPath Integration process wizard in either K2 blackpearl or blackpoint
  • Click on the Design button
  • When the form loads, go to Tools/Form Options select the category Open and Save
  • Click the Rules button under the Open behavior section
  • Select one of the rules and select “Modify”.
  • Click OK
  • Click OK again until you are out of the Form Options
  • Save the form
  • Close the form
  • K2 will tell you the form template has been successfully been updated

What this does is resets the rules for the form options and cleans out the ones that are empty in the manifest. (I actually added an generic rule and then went back and deleted it and this also force the form to refresh).

At this point, you can go back to the InfoPath client events and associate the event with the correct view and finish the wizards. If you go back and open the form, it should have the new rules associated with the views that you just associated with in the wizard.

Deploy the process as usual.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5