Wednesday, May 28, 2008

Writing custom code in a K2 blackpearl client event

Long time no blog...

Topic that’s had some recent airtime in Dynamyx. How to, or more specific, what’s the most correct way to write custom code behind a K2 blackpearl client event. This specific use case came about when we had to send an email from the client event that needed a high level of customization.

Firstly, looking back at the K2.net 2003 days, this was a simple right click on the client event and hacking away at the generated code. The drawback was that you bought a one way ticket... you could never run the wizard again and retain your custom code. The new K2 blackpearl authoring model allow us to customize the underlying code of an event but maintain the integrity and ability to re-run the event's wizard.

The question is, where do you put your code then?

Let’s start by looking at the code behind a client event. Right click on the client event and select the View Code Event Item option:



You'll be presented with the XOML schedule that makes ups the client event:

The idea is to add you own WF code activity either before or after the core client event code (depending on what you want to do). In my example I dragged a simple WF code activity from the Visual Studio toolbox and dropped it at the end of the schedule. To get to the event handler of the code activity, right click on it and select Generate Handlers:



And write you own custom code:

Thanks to Colin Murphy and Jey Srikantha (fellow K2 insiders) for their input in this solution.

5 comments:

Chris O'Connor said...

Good article - was so wasy to add code in K2.NET 2003 - but the new WF layouts are a bit trickier, and haven't actually had the need to add code (yet). Thanks again...

Chris O'Connor said...

oops - comment should have read : was so "easy" - not "wasy"...

Anonymous said...

Evil IT Resources page http://resursi.wordpress.com
(IT management in Eastern Europe, HR, politics and other things)

Sophie said...

Hi,
I am Programmer with Chessboss.com. Chessboss.com is absolutely FREE chess server where you can play chess,create your own tournament with players online. No Gambling and explicit talk. This website is purely meant to increase the fan-base of chess and for entertainment. I Need your help to promote the FREE chess server around the world. I would like to be on your blog as i found it a useful and informative resource. By adding chessboss.com you will recognized and added as a top resource on our chess server. I really believe in FREE flow of information. I have included the code and title.

Please email me back with subject line of your URL for the featured resource code. This is to avoid spam and to make sure you get the award.

I hope you understand and co-operate with us.

Thank you,
Sophie Vierra
Programmer
www.chessboss.com.

ADmin said...

This article gives 6 exposition composing tips that dissertation writing services will take you from a beginning thought through to the completed item.