Tuesday, August 2, 2011

Unit Testing K2 Processes

Discusses how to build automated unit tests in Visual Studio that test K2 processes. The document also includes best practices such as testing scenarios versus testing methods, testing line rules, testing task assignments, using the K2 reporting SmartObjects to test activity execution, using XML files to test InfoPath forms, substituting K2 SmartBox SmartObjects for SmartObjects that connect to external systems to mock the external systems during testing, and giving process rights to the build process.
In addition to the best practices the document also includes examples on how to perform common development tasks such as starting a process, getting a worklist, submitting an action for a worklist item, ensuring an activity is executed, and a list of scenarios for testing a sample K2 process.
Also, see the accompanying source code file that includes the sample K2 process, a framework project for performing many of the common development tasks, and a unit test project that tests the sample K2 process.
The files can be found on the K2 Underground here.
Thanks,
Roy Higgs

Wednesday, May 11, 2011

K2 Service Account as Site Collection Administrator

You've developed your K2 process and have deployed it so you can begin to test it. But you're now presented with this elusive error message:

Unable to modify workflow : Server was unable to process request. ---> Attempted to perform an unauthorized operation.

Fortunately, there is an easy fix for this. Simply add the K2 Service account as a site collection administrator and you'll be on your way to testing your next new great process!!!

Thursday, April 14, 2011

K2 Destination User for Plan Just Once Activity


In your K2 process you may want to know who actioned a workflow item so that you can save the user information to a SharePoint list or display it on your user interface in a later step. However, when you have a destination rule for an activity that is Plan Just Once you are unable to retrieve the destination user from the User object in the Activity Destination Instance node in the Workflow Context Browser.



To retrieve the destination user for a Plan Just Once activity you can use a SmartObject Event to call the Activity Instance Destination List method. Add the SmartObject Event directly under your client event in the same activity as the client event. In the screenshot below the SmartObject Event is the Save Destination User event.



In the SmartObject Event select the List method under the Activity Instance Destination SmartObject as shown in the tree below:



On the next screen drag over the Activity Instance ID field to the Activity Instance ID input variable:



On the Return Mapping screen map the Destination variable to a process data field:



Finish the SmartObject wizard.

Finally, ensure that your process has a SmartObject Association with the Workflow Reporting SmartObjects. To do this, launch the SmartObject Association Wizard (in Visual Studio the button to launch the wizard will look like the first screenshot below) and check the Create Workflow Reporting SmartObjects checkbox.



Now you have your destination user available in a process data field to user at a later step in your workflow.