Events nodes in K2BTools Patterns


In some scenarios the application requirements cannot be met using the configuration options given by the properties offered by K2BTools patterns. In some of those scenarios, the developer may wish to add custom code to the generated object to implement those requirements.

K2BEntityServices and K2BPrompt contain a mechanism to enable this, using the Events and Subroutines and EventOrSub nodes.

How to add custom code to an existing event (or subroutine)

To add custom code to an existing event follow these steps:

  1. Add an "Events" node to the instance in the scope where the event exists (the image shows how to add an "Events" node to a WorkWith).
    Adding an events node

  2. Add an "Event" node inside the "Events" node created in the previous step.
  3. Set the "Event" node properties:
    1. Use the "Name" and "Type" properties to identify the Event or Sub where the code should be added.
    2. Use the "Begin Code" and "End Code" to include the code that will be added to the Event or Sub.


In this example, we will add code to a WorkWith Start event. This event is generated by K2BEntityServices with an standard content, shown in the following image.

Code generated by K2BTools

To add code in this event, Events node should be created as explained above.

Instance Definition

After this is included in the instance the Start event's content will change as shown below.

Updated code