We're updating some of our product names. K2 Five will soon be Automation On-Prem. You may see both product names in our help pages while we make this change.
Writing Custom Code in workflows when using K2 for Visual Studio
This content applies to legacy components
(such as K2 Studio and K2 for Visual Studio), legacy assemblies and APIs, legacy services or other legacy functionality. These legacy items may not be available, supported, or behave as described, in future updates or versions of K2. Please see the
legacy component and API support policies for more information about support for these components
When using K2 for Visual Studio to build K2 workflows, it is possible to write your own custom code by using the Default Server Event Wizards, or by accessing the code generated for a workflow and modifying that code.
This section describes how to write custom code in server events in a workflow. Developers can write their own code in K2 workflows using the Default Server Event (Code) or Default Server Event (WF) K2 event templates, or can modify the code in any workflow item by using the View Code option for components in the workflow design such as lines, activities, events, escalations, exceptions.
This capability allows developers to create or modify code so that the workflow does exactly that they need it to do – they are not limited to the standard functionality provided by K2 wizards
You can only write code in server events when using K2 for Visual Studio. Other workflow design tools like K2 Studio and the web-based workflow design tools do not offer a code editor and therefore will not allow you to access the code behind server events. However, you are able to create a process in K2 Studio, save it, then open the process in K2 for Visual Studio and write custom code, save the process and then open and continue editing the workflow with K2 Studio again. Your code customizations will still exist, but cannot be modified by the K2 Studio design tool.