Welcome to K2 Underground Sign In | Join | Help

Johnny's K2 Blog

Just a place to share my K2 related thoughts/tips/tricks with the community. - Johnny Fang, Solutions Manager, K2
Cool Things about the Publishing Event Wizard

Ever notice that this little wizard in K2 blackpearl could do quite a lot of things with the new Content Management features in MOSS 2007?  [For the uninitiated, the features of the now defunct Content Management Server 2002 were merged into MOSS 2007 aka "The Borg" style.]

 Besides the standard page publishing actions such as Create, Copy, Move, Update, Check In and Delete.

 You could also:

  1. Get Page Content from a page and dump it to an XML field.  This allows you to access the attributes of the page and also the contet that you are trying to access.
  2. Create Page from a Convertor.  You can create a page from a document source such as InfoPath, Word Documents and also XML.  Just specify the location of the document, the convertor and the page title and bam, you are done.  Pretty cool stuff.
  3. Create or Update Reusable Content.  This ties in to the other publishing page functions where you are assign reusable content to pages.  Reusable Content is a MOSS feature that allows you to bind dynamic content that can be shared across pages.  This blog post from Amanda covers this topic pretty well (http://blog.funknstyle.com/?p=577).

Pretty impressive stuff from a single wizard that allows you to do all these without a single line of code.... Cool....

Silverlight 2 and K2

Here's a good blog post by Scott Guthrie on Silverlight 2.  The latest K2 Silverlight Web Designer in blackpoint is also featured in the post.

Cool stuff.    :)

http://weblogs.asp.net/scottgu/archive/2008/11/16/update-on-silverlight-2-and-a-glimpse-of-silverlight-3.aspx

Finding Duplicate SPNs

Sam pointed out that Microsoft had a nifty little script which helped you to find duplicate SPNs.

http://forum.k2workflow.com/forums/thread/27093.aspx

This would be pretty useful for troubleshooting purposes when other people are messing around with your SPNs.  :)

K2 Tips and Tricks (and Gotchas) in 0807

Here's a couple of tips and tricks (and warnings) in 0807 that I noted while using it over these few days.

  1. When opening a new or current K2 process, occasionally you might not see the Process/Activity Data and Workflow Context Browser panes in the K2 Object Browser.  One way is to just close and reopen the Process design canvas.  However, a quicker way I noted was to just click on an open process canvas, this immediately pops up the two additional panes.
  2. When designing a new solution, just close the existing solution instead of closing Visual Studio completely (From the menua File -> Close Solution).  The upside of doing this is that it leaves the cached modules in memory.  So creating a new process is quite zippy.  The same applies for opening a current complex process.  When you open it the first time, it takes a while to cache up the modules that it needs.  However, if you close the process canvas (while keeping the solution open), opening it the second time is very zippy.  The same applies to most of the wizards as well.  i.e. running it the first time is slower but the second time is zippy.
  3. IPC Event Template - Avoid switching sync modes after you have configured it (e.g. changing Sync to Async).  Switching modes causes you to manually fix the field mappings again and you need to manually set the data direction for each one.
  4. Update Design Template feature - To take advantage of new performance improvements (e.g. InfoPath and SharePoint templates), you need to update the templates in your solution to get the updated code changes for the templates.  However, one big gotcha here is that any code customizations will be removed during the update (except for code in Server Event templates).  If you accidentally wiped out your code changes, don't fret.  Just get a backup copy of a previously deployed version from the K2 workspace process management node.
  5. In previous versions, a temp class file would be generated for all the objects in the process.  Notice now that the temp files for the workflow extenders are no longer in the project directory.  You can also no longer access them via the solution explorer (Show extender projects button).  This has been removed to work better with TFS as previously checking in those files will cause havoc when other developers check out the solution.  Some people might ask "how do I add web service or assembly references then?".  Take note that you shouldn't be adding references from here but you should be adding references from the "Project References" icon on the top right of the process canvas.  So the question is where are the temp extender files now?  You can actually see them being created in C:\Windows\Temp.
  6. It's interesting to note that the code templates for the K2 Designer for Visual Studio are located in C:\Program Files\K2 blackpearl\Bin\DesignTemplates\CSharp\WindowsWorkflowExtender\1033.  Note do not make backup copies of the .cs files inside the same folder.  You will have build errors on the extenders complaining that the members already exists.
  7. It's also interesting to note that the default blank template for the Forms Generation Client is located in C:\Program Files\K2 blackpearl\Bin\layouts\ClientEvent\CSharp\1033\Blank Page.  You can make a copy of the folder and rename it to something else.  This will allow you to create and customize new templates that match the look and feel of your company.  You will notice it's just .cs files and css style sheets inside.  You will also note that the pages all get deployed to C:\Program Files\K2 blackpearl\WorkSpace\ClientEventPages.
  8. If you have difficulties getting the ViewFlow control to install correctly (especially if you have limited permissions on your machine).  You can extract the ViewFlow control installer from here (C:\Program Files\K2 blackpearl\WorkSpace\Site\TaskListControl\K2ViewflowDeployer.cab) and get your local administrator to install the msi file for you.  Alternatively, you could even deploy this via a software policy in AD (I haven't tried it yet but I believe it should work as the control is packaged as an msi file).
  9. Note that in the SourceCode.Workflow.Client API, the ProcessInstance.Update() method now requires Admin permissions to execute.  This is intended by security design.  To update data fields via the client page, use a Action configured in your client event but set it to update the workitem rather than complete the workitem.

Ok, that's about it for now.  I'll add on more to this article as I find out more stuff.  If you have anything interesting to share.  Feel free to send me an email (johnny@k2.com) and I'll put it into the list (with credits).  Cheers.

 

0807 Re-released!

New version of K2 0807 has been re-released on the customer portal.

New version is 4.8210.2.0.  This version contains the following critical fixes.

KB000301 - Error when using a K2 Process with a Document View Enabled

KB000302 - The Event Instance Report Causes an OutOfMemory Exception

KB000303 - Exception when an InfoPath form calls a SmartObject's load method

KB000304 - Patch: Active Directory Query Locks Server and Returns No Results

KB000305 - InfoPath Form opens in InfoPath client instead of Forms Services

KB000311 - Error in Out of Office with adding a User to Forward List

 Note that customers on 4.8219.1.x versions can download the individual patches and apply them to their setups to get to the same level.  If you prefer a clean install, you can uninstall the K2 components and retain the databases.  From here, you install the new version and point it to the saved databases.

0807 and InfoPath Client Event Template

As many of you may know, 0807 just got released last week and there's a whole bunch of snazzy stuff inside. 

However, take note that there is currently a known issue that can cause some problems for those working with Form Services.   For a new 0807 process applications, the InfoPath client event does not open correctly as a web page (instead it opens it using the Thick InfoPath client). Current upgraded processes from pre-0807 (e.g. 0803 or SP1) will still run fine as the IP templates are using the previous versions.

 Note that this can be corrected in the code view for the InfoPath client template.  *But* unless you plan to correct the code for every single InfoPath client event, I would advise holding off on the 0807 upgrade until the patch is out for the template (which should be soon).

0807 RTM has been released!

Just to let everyone know that the new K2 blackpearl 0807 has been released on the customer portal.  This is a milestone release as this includes a big bunch of performance and stability enhancements.

New features are the Out-of-Office components and the K2.net 2003 interop components.

Here's the official summary from the release notes. 


PERFORMANCE ENHANCEMENTS
Numerous performance enhancements have been implemented. Some of the highlights are as follows. Workflow Server Performance

> Improved processes execution
> Worklist & Worklist Item performance
> Worklist enhanced paging and filtering capabilities
> More granular selection on Workflow Reporting SmartObjects
> Improved memory usage on K2 Designer for Visual Studio
> Improved memory usage when starting processes and finishing work list items
> Improved batch execution of K2 processes
> SmartObject Performance (runtime execution)
> SmartObject Server data handling enhancements

ENHANCEMENTS ON K2 WIZARDS
Some changes have been made to the functionality which resides behind the scenes of the K2 Wizards – specifically the items used for Microsoft SharePoint Server integration. These wizards now leave a smaller footprint on the process definition (.kprx) files, resulting in smaller file sizes and better memory management in the different designers available for K2 blackpearl.


DOCUMENTATION

Several additions and enhancements have been made to the K2 blackpearl Documentation. The key areas of improvement are as follows.


OVERALL DOCUMENTATION

Certain topics of the K2 blackpearl documentation has been updated and new topics added. New or updated topics are marked with an asterisk image in the Table of Contents

The following sections contain new or updated information:

> K2 Concepts - Content Fields
> K2 Wizards - Chaining wizards
          > Mail Event
          > IPC Event
          > SharePoint Records Management Wizard
          > Deploy Project Wizard
> K2 SmartObject Integration - SmartObject Association
> K2 for Visual Studio - K2 Design Canvas
> K2 Interop
> K2 Workspace - Management Console
          > Out of Office
          > Standard Reports
          > User Preference
> K2 Developer Reference - Architecture of K2 Platform
          > Users
> Extending the K2 Platform

 

0807 Public Beta Released!

Just to let you know.  The public beta for 0807 has hit the customer portal site (http://portal.k2workflow.com).  So if you are marked as a beta user, you will be able to download and test drive this from the downloads section under beta components.  If you don't see it, request your local support to add you in as a beta user.

Note!  This version has been delayed for a while as it has gone through more stringent QA cycles and has a host of performance enhancements.  However, this will not be upgradable to the final 0807 RTM.  So do not install this in any environment except test environments.

I have updated the list of stuff that is in this release in my previous blog entry.  So you can see the changes here.  http://forum.k2workflow.com/blogs/johnny/archive/2008/07/26/0807-early-impressions.aspx 

Enjoy. :)

Difference in RepairError behavior in K2.net 2003 and K2 blackpearl

I saw this response from Blake (http://forum.k2workflow.com/forums/thread/25502.aspx) and I thought it interesting that the RepairError behaviour has changed.  I did some research on this and I thought it would be nice to share out my findings on the key changes in the RepairError bahaviour.

In K2.net 2003, the repair error would affect the code of the version that the process instance is running on.  So any changes would impact any running instances which is on the same process version.  Checking the “Repair All Instances” option was primarily to auto-retry all the error instances having the same error. Otherwise, I would have to retry each error instance individually, this could get tedious if there were a lot of similar errors.

It seems that the repair error behavior is different in K2 blackpearl as it creates a new version and re-runs the error instances on the new version. 
Depending on what is specified for the “Repair All Instances” option.

  • Checked – Deploys a new version and retries all instances with the same error on the new version.  The new version is also set as the default.
  • Unchecked – Deploys a new version and retries only the specific instance.  The default process version is not changed.

So this option now becomes quite useful in different scenarios.

  1. Unchecked – I have a specific error instance which is caused by a specific data error.  I could do some custom code to hard code the invalid values without impacting the other instances.
  2. Checked – I have a general error in the process which needs to be fixed across all running instances.

I hope this article helps you understand the differences in the options and also how they function when doing a RepairError.

Quick Tip: How to connect a line back to the same activity

As most people would know, it's a pretty simple exercise in K2.net 2003 to draw a line back to the same activity.  You just have to pick the "U" shaped line type and draw it directly.

 This is pretty useful for cases where you want to do ad-hoc approval routing where the current approver can select another approver from a drop down list in the approving form.  Effectively the line rule just checks if the field containing the next approver name is empty or not.  If it is not empty, it will route back to the same client activity but with the selected user as the destination user.

Now, this can also be done with K2 blackpearl, but it isn't too obvious with the current line behavior.  When dragging a outcome line from a client activity and then trying to drag it back to the same edge, you will notice that the line jumps around instead.  This gets a bit annoying if you are expecting it to behave like K2.net 2003.

However, here's a quick tip for a sure fire way to get the loop back line drawn correctly (and nicely) each and every time.

  1. First move the start of the line to the left or right of the activity box.  You need to see the hand icon appear before you can move the start of the line.
  2. Next click and hold down the mouse button after you select the end of the line (i.e. the part with the arrow head).  Same as before, you need to see the hand icon appear before you can do this.
  3. Now just drag the arrow head back to the centre of the activity box.

Now once you have done this, you will notice that it drags a nice loop back from the side of the activity box back to the top of the activity box.  You can try this a few times and the behaviour is always consistent.

Easy Peasy, right? :)

Differences between "Plan just once" and "Plan per destination"

There are some of us who come from a K2.net 2003 background and we tend to bring the concepts of K2.net 2003 destination rules and Destination Queues along with us when we use K2 blackpearl.  I was no exception to this.

However, while having a discussion with some of the labs guys on a feature request, I discovered my understanding of how slots and the various destination rule options work was totally wrong!

Yes, K2 blackpearl and K2.net 2003 destination rules work quite differently.

Take this example:

I have a client activity where I want to do a voting scenario.  I want to route it to a pool of 5 users.  I want my item to be approved when 2 of them approve it or 1 of them rejects it.

 Now in K2.net 2003, you would set 5 users into your destination rules and set 2 slots in your activity.  Now, when this activity instance is created; in the worklist table, you would see that 5 records in the worklist table will get created (i.e. one for each user).  As soon as the first two users action on their workitems, the other 3 workitems in the other 3 user's worklist will get expired.  Now, that isn't too efficient if the number of users increases in the destination pool.  e.g. a call center can have maybe a 100 operators serving workitems.  Of course in K2.net 2003, there is a way to work around it by using the optimization for the destination queues.  This allows you to create a single entry in the worklist table for a destination queue.  So in the worklist table, you would see that the item is assigned to the queue name instead of the user name.  The item will be assigned at the point where the first user picks up the workitem.

Now in K2 blackpearl, if you have the same scenario.  This varies depending on which option is being used in the client event options.

Plan Just Once - This option instantiates only one activity instance regardless of the number of slots.

So it would look something like this.

ActivityInstanceDest 1

         |____  Slot 1

         |____  Slot 2

Note that as there is only one activity instance, any events in the activity will only fire once regardless of the number of slots.

So you will note that you cannot:

  1. Assign the destination user in the notification email.
  2. You cannot get the User and Action Result properties from the ActivityInstanceDest object.

The whole reason here is that events and succeeding rule in the activity instance will only fire once.  So the results of the users are actually stored in the slots collection.  However, what is interesting is that there is intelligence in the succeeding rule logic.  If you have your succeeding rules to complete if 2 or more slots approve or at least one slot rejects.  The succeeding rule will fire as soon as 2 of the slots have Action Result = Approve or 1 slot has Action Result = Reject.  Note that for the "Plan Just Once" option, the succeeding rule will always fire the SetSucceedingRuleTrue handler in the code for the Succeeding Rule.  The SetSucceedingRuleFalse handler will never fire.

Plan Per Destination - This option instantiates one activity instance per slot.

So it would look something like this.

ActivityInstanceDest 1

         |____  Slot 1

ActivityInstanceDest 2

         |____  Slot 2

Note in this case, any events in the activity will only fire based on the number of instances (in this case it is 2).  Also there is a one to one relationship between the ActInstDest and SlotInstance objects.

So you will note that destination user in the notification email functions as expected and the the User and Action Result properties from the ActivityInstanceDest object are populated as well.

So in the same example above, if you have your succeeding rules to complete if 2 or more slots approve or at least one slot rejects.  If the first user approves, the succeeding rule will fire the first time.  However, as the succeeding rule condition has not been met, the SetSucceedingRuleFalse handler will fire first. Now if a second user either approves or rejects, the succeeding rule will fire again.  This time the SetSucceedingRuleTrue handler will fire.

Last Thoughts

Now after digesting all this, you can probably see that there is a performance benefit in K2 blackpearl when dealing with large number of users.  For a destination rule pointing to a hundred users while working on a activity with 2 slots.  Only two slot records get created versus 100 worklist records in K2.net 2003.  User resolve their worklist at runtime and slots are assigned to users in real-time as well.  Isn't this great?  :)

0807 Early Impressions

[Updated 2 Sep 2008] 

Been trying out the betas of 0807 and I must say there are a couple of pleasing changes from 0803.

  1. K2 reports - improvement in performance overall due to moving the paging/filtering from the web server end to the database backend.
  2. K2 Workspace
    1. Archiving works seamlessly now.  :)
      • Create a blank database in SQL Server Management Console
      • Go to the Archival node, specify the source database as K2ServerLog and the destination as the newly created DBs.
      • Specify the To and From dates and then run the Archival!  It's that simple.
    2. Permissions listing has been enhanced.  Columns can now be sorted ascending or descending.
    3. Enhanced dialog for adding user/group permissions
    4. Workspace Node 
      • Additional setting for the workspace to control the display items per page for users.
    5. User Managers Node 
      • Additional setting to specify the limit for the number of users returned for the URM service.  Default is 100.
      • Additional place to add other trusted domains for users. -> No more fudging in the database.
      • Additional options in the UI to resolve nested groups and also other AD query related settings. -> No more fudging in the database.
  3. K2 designer for Visual Studio
    1. Much improved memory usage - I was able to create up a process with 100+ activities and memory consumption was slight above 600MB.  Nice!
    2. Wizards are also a lot zippier.
  4. Out of Office feature is now in
    1. The cool thing is that it uses the delegation feature.  So the workitems can be seen on both your worklist and your delegate.  You can even have a couple of people to be your delegate.
    2. Out of office settings can be managed by users directly from the worklist or by the administrator from the management console.  Very nice!
  5. Installer has a number of improvements - The one I like is that it now creates the SPNs on the FQDN name of the K2 farm now.  Nice!
  6. K2.net 2003 Interopt (going RTM in 0807) - My colleague DC has been testing out a bit for a migration project and there were a couple of issues since Build 002.  However, it's pretty cool that in Build 010 most of the stuff is now working (even for K2.net 2003 VB processes).  You can edit the Interopt Activity wizards to change the destination rules and also edit the Destination Queues from the "K2.net 2003 Destination Queue Property Wizard" on the Process Wizard Strip on the top of the canvas (though the editing code only made it into Build 011).

There's probably a ton of other fixes and enhancements as well but these are the more noticeable improvements just from playing around with it for a few days.

Updating Batch Action/Outcome results back into InfoPath form

I got posed this question the other day and I thought this might be useful to share.

The scenario is that when do a batch selection or quick approval action from the worklist, the outcome is not recorded into the form's audit history.  Of course, the process audit history will have it but in certain cases, the user does not have access to the process history information.

So if we wanted to store the outcome in the InfoPath form data, basically we have to update the value directly within the succeeding rules of the client activity.

Here's an example. Edit the code of your succeedin rule.  You can get the final outcome by putting this snippet of code inside the succeeding rule.  See portions in red.  The text in green is the variables you need to change to your own form and namespace.

  using System.Xml;

        public void Main(Project_282cb15964ee4ab397715563ff6641a6.SucceedingRuleContext_369ef228d5e54527b7116b0583eabd22 K2)

        {

            if (SucceedingRuleHelper.AnyOutcomesEvaluatedSuccessfully(K2))

            {

                AllInfoPathTasksFinished(K2);

                K2.SucceedingRule = true;

                XmlDocument xmlDoc = new XmlDocument();

 

                xmlDoc.LoadXml(K2.ProcessInstance.XmlFields["TestForm"].Value);

 

                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);

 

                namespaceManager.AddNamespace("my", xmlDoc.DocumentElement.GetNamespaceOfPrefix("my"));

 

                xmlDoc.SelectSingleNode("my:myFields/my:myDataField", namespaceManager).InnerText = K2.ActivityInstance.DataFields["Outcome"].Value.ToString();

 

                K2.ProcessInstance.XmlFields["TestForm"].Value = xmlDoc.OuterXml;

 

            }

            else

            {

                InfoPathTaskFinished(K2);

                K2.SucceedingRule = false;

            }

        }

 

Addendum:

If you are using the "Plan Just Once" option, you should note that there is only one Activity Instance created with 1 or more slots tied to it (See my article on this).  So if you want to enumerate through the list of actions, here's a code snippet to do this.

            for (int i = 0; i < K2.ActivityInstanceDestination.ActivityInstance.WorklistSlots.Count; i++)

            {

                Console.WriteLine("Action Result: " + K2.ActivityInstanceDestination.ActivityInstance.WorklistSlots[i].DataFields["Action Result"].Value.ToString());

                Console.WriteLine("Destination User: " + K2.ActivityInstanceDestination.ActivityInstance.WorklistSlots[i].User.Name.ToString());

            }

 

Upgrading from SP1 installation with non-standard paths to 0803

Tried this out with a customer over the past 2 days where we were trying to do an upgrade for a 2 node K2 server farm (K2 Host Server and Workspace together) with a SQL cluster backend.

Typically if the installation is done on a standard path configuration, it should go pretty smooth.  However, the caveat here was that they installed SP1 on E: drive.

This causes the following issues:

  1. After running the installer, the configuration manager does not start automatically.
  2. If you try to run the configuration manager manually, the configuration manager thinks it is a new setup and will prompt you to install everything afresh.

To get around this, you need to do the following:

  1. Modify the configuration.config file in E:\Program Files\K2 blackpearl\Configuration.  Note the following connection string inside.  You need to modify localhost to the correct database server name.
    • <add key="connectionString" value="server=localhost;database=hostserver;integrated security=sspi;" />
  2. Re-run the configuration manager manually.
  3. Now it will run the upgrade process instead of installing new databases.

Now there's one more issue here that you need to take note of.  Due to the path issue, the upgrader doesn't run the SQL update scripts correctly.  This means that after the configuration manager finishes, the K2 databases are still not upgraded.  You can check the database version number from the K2Server database in the _Setting table. The version field should be 4.7285.1.0 (SP1).

At this point do not panic!  There is a workaround to fix this by manually running the database upgrade scripts in the SQL Management Studio.

These scripts can be found in E:\Program Files\K2 blackpearl\Configuration\Script.  However, you will need to do a bit of search and replace in some of these files before you can run them.

Make a copy of the following 6 files before modifying them.

  1. HostServerAlter.sql - (with relevant placeholders replaced like)
    • [NETBIOSNAME]
    • [NETLDAP]
  2. K2ServerAlter.sql
  3. K2ServerLogAlter.sql
  4. HostServerReconfigure.sql – (with relevant placeholders replaced like)
    • [NETBIOSNAME]
    • [NETLDAP]
    • [K2SQLUMDBSQLSERVER]
    • [K2SQLUMDBNAME]
  5. K2Reconfigure.sql – (with relevant placeholders replaced like)
    • [LBHOSTSERVERNAME]
    • [HOSTSERVERPORT]
    • [ADMINUSER]
    • [USERSNAME]
  6. K2LogReconfigure.sql

Note the subitems are the tags to be replaced.  The values can be obtained from the HostServer database in the Configuration table.

One final point here.  Before doing any upgrade, do a full backup of the servers and also the databases (shut down the K2 servers on both nodes before doing the backup).

This will give you the peace of mind that you can always roll back if something doesn't go right. 

 I hope this makes it easier for anybody trying to do an upgrade from SP1 to 0803 where they install in non-default paths.

Tip of the Day: Freeing up memory used in K2 Designer for Visual Studio

During the course of designing a process and running the designer for a while (I am using build 0803), you might find that your designer is taking up a lot of memory. Sometimes you would normally close and reopen the designer to start afresh.

However, note that you can try this trick where you can minimize the window and your devenv.exe process memory usage should drop dramatically.  My process memory usage dropped from 200-300MB to 20MB.

Hope some of you will find this useful.  Cheers!

More Posts Next page »