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)

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.

Professional Writers Online said...

Are you looking for professional reliable position paper writing help , look no further, we have reliable Nursing PICO Essay Writers UK for professional assistance. Let help with your nursing assignments as our Business Statistics assignment writing services are affordable and reliable. Write to us today for Custom Dissertation Writing services as well as Top-quality Interview Script Writing Services and reliable survey questionnaire development help