Starting a K2 process in an ADO.NET Application

A K2 process can be started in various ways using an ADO.NET application. The K2 process surfaces in the data provider and can be linked to certain controls on an ASP.NET Web site. The workflow process needs to be assembled and deployed either in K2 Studio or K2 Designer for Visual Studio prior to the form creation. The process's entities are created as SmartObject properties that are visible in the SourceCode blackpearl Data Source.

Either a SQLDataSource or an ObjectDataSource can be used to create the connection to the process. Select the New Connection button to configure the connection. When selecting a SmartObject to provide the data in the Add Connection window browse to the Workflow folder and select the required K2 process.

Fig. 1. Example of a K2 workflow process surfaced as a SmartObject

Setting up the connection will surface the required workflow SmartObjects as Stored Procedures to start, approve or decline a process as displayed below:

Fig. 2. K2 workflow SmartObject available as a Stored Procedure

It is important to select the correct SmartObject property for each of the SQL statements to ensure the correct action is performed on the K2 server. For Example:

  • The [Investment_Investment_Approval_Manager_Approval.LoadWorklistItem] will be selected for the SELECT tab enabling the data to be returned from the server.
  • The [Investment_Investment.StartProcess] will be selected for the INSERT tab enabling the data to be returned from the server.
  • The [Investment_Investment_Approval_Manager_Approval.Approved] can be selected under the UPDATE tab to update the K2 server.

 

Link a K2 process to a SmartObject Method

The workflow SmartObject properties can be surfaced in other SmartObject' s methods (Example A) or even created as a SmartObject Method (Example B). This allows a developer to create a SmartObject Method that will start a process in the form.

Example A: The process will be started automatically as soon as the SmartObject is created as the K2 workflow has been linked to the SmartObject's existing Create Method. If the Create method is selected in the data provider as the INSERT Stored procedure it will result in the workflow firing as soon as the SmartObject is created through the ADO.NET form.

Fig. 3. Create a Start SmartObject Method

Example B: A SmartObject Method can be created to start the process. The Method will surface in the data source and can be assigned to the ADO.NET form.

Fig. 4. Create a Start SmartObject Method