Using the GoToActivity method to move a process instance

  • 15 February 2022
  • 0 replies
  • 331 views

Userlevel 5
Badge +20
 

Using the GoToActivity method to move a process instance

kbt154330

PRODUCT
K2 Five
BASED ON
K2 Five 5.1
TAGS
API
Workflow
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

Objective

How to use the GoToActivity method of the Workflow Management API to move a process instance to a different activity.

Before You Begin

The K2 Five developers reference documentation has examples and information on the API: Developer Reference.

 

 

 

How-to Steps

Example code for an API call to use GoToActiviy:

SCConnectionStringBuilder builder = new SCConnectionStringBuilder();
builder.Integrated = true; //use the current user"s security credentials
builder.IsPrimaryLogin = true; //true = re-authenticate user, false = use cached security credentials
builder.Authenticate = true; //whether to authenticate the user's credentials against the security provider, usually true
builder.Host = k2Server2; //the name of the K2 server
builder.Port = 5555; //you must use port 5555 when connecting with the management API
builder.SecurityLabelName = "K2"; //this sample uses the Active Directory security provider 
K2MgmtServer.Open(builder.ToString());
K2MgmtServer.GotoActivity(ProcessInstanceId, "Task");

The line of importance is: K2MgmtServer.GotoActivity(ProcessInstanceId, "Task"); 

The API makes a call to K2 and utilizes the system name of an activity. In K2 Designer, the display name of an activity may be modified, but the corresponding system name is untouched. For instance a default user task will have the system name of "Task." A second added user task will have the display name of "Task 1".

 

When using the API call, be sure to reference the desired activity by the system name. To verify the system name of the activity you are looking for, the following database query can be run.  This query takes the workflow display name and returns the matching display and system name for the workflow's activities.

Declare @WorkFlow NCHAR(50)
Set @WorkFlow ='Workflow DisplayName Goes Here'
SELECT [DisplayName], [Name] AS 'System Name' FROM [K2].[Server].[Act] WHERE ProcID = (SELECT ProcVerID From [K2].[Server].[ProcSet] Where [DisplayName]= @WorkFlow)

 

 

 

 

 


0 replies

Be the first to reply!

Reply