Live Instance Management (LIM) in SourceCode.Workflow.Client

In terms of Live Instance Management, the relevant methods in SourceCode.Workflow.Client allow you to force the process to go to another activity, optionally expiring any other active activities or not. You cannot use SourceCode.Workflow.Client to force a process to migrate to a different version of the workflow.
SourceCode.Workflow.client
Class Name Method Name Argument Name Argument Description
WorklistItem GotoActivity Activity The Destination Activity Name to where the Process should go to.
ExpireAll Expire all Activity Instances on the process instance, or only the current Instances for the Activity
Sync Perform the GotoActivity Synchronously or Asynchronously.

GotoActivity(string Activity,  bool Sync, bool ExpireAll)

Expires the activity that the worklist item is a member of, and forces the process instance to start an instance of the activity in the ‘Activity’ parameter.

  • If ‘Sync’ is true, the call does not complete until the next wait-state is encountered, such as a client event or start rule.
  • If ‘Sync’ is false, the call will complete immediately.
  • If ‘ExpireAll’ is true, all active activity instances in the process are expired, including concurrent activities.
  • If ‘ExpireAll’ is false, only the active instances for the current activity in the context of the worklist item is expired.
Parameters:
  • Activity is the name of the activity to go to.
  • Sync specifies whether the method call should return immediately or only once the next client event in the process is encountered.
  • ExpireAll specifies whether all current activities in the process should be expired, or only the activity that this worklist item (client event) belongs to.

The ‘Sync’ parameter’s behavior is the same as in the classic wli.Actions[1].Execute(sync) method.  In practice, this means that the method call will not complete until the next client event in the process flow is encountered.

If the ‘ExpireAll’ parameter is not provided, all active activity instances will be expired. This usually applies in workflow instances where different activities are active at the same time, for example workflows with parallel paths.

Copy

Example of GotoActivity parameters

//open a simple connection
K2Conn.Open("localhost");

//obtain the serial number and open the worklist item
string serialnumber = "[ProcinstId]_[ActInstDestId]";
WorklistItem wli = null;
wli = K2Conn.OpenWorklistItem(serialnumber);

//force the current process instance expire all current activities asynchronously
//and create an instance of the Activity "SomeActivity".
wli.GotoActivity("SomeActivity", false, true);
//force the current process instance to only expire the activity that this worklist item belongs to
wli = K2Conn.OpenWorklistItem(serialnumber);
wli.GotoActivity("SomeActivity", true, false);

Considerations

  • When a process instance is in ‘Running’ status, it means that K2 server is busy executing code for the specific process instance. It is NOT possible to intercept the executing code, or to manage the process instance while it is in ‘Running’ status. Therefore, the only statuses supported for managing process instances are ‘Active’, ‘Error’ or ‘Stopped’.