How to get/check status of an activity instance from c#?

  • 22 December 2017
  • 2 replies



I want to bulk change running workflow instances and jump to a specific activity by using the Workflow Management APIs GotoActivity method. But before just ending the workflow instance, I want to make sure that the currently loaded instance is at the expected Activity and that activity is in Status=Active.


How/where do I get the currently active activity for the workflow instance and see its status is Active?

When I examine the Activity class there is no Status property.


I use something like this:


WorkflowManagementServer wfmServer = new WorkflowManagementServer();



Activities acts = wfmServer.GetProcInstActivities(12345);

wfmServer.GotoActivity(procInstance, "Finish");



Best regards, Peter

2 replies

I have solved my problem for now by verifying Activity Instance Status through the SmartObject Client framework. 


I used K2 SmartObject Tester to create C# class for the Activity Intance SMO.


After that I can do something like this:


Activity_Instance ai = new Activity_Instance(ConfigurationManager.ConnectionStrings["k2db"].ToString());
ai.ProcessInstanceID = procInstance;
ai.Status = "Active";
ai.ActivityName = "Activity name of where I expect this process instance to be situated at";
DataTable dt = ai.List();


if (dt.Rows.Count == 1)

  wfmServer.GotoActivity(procInstance, "Finish")





Badge +7

Hi  @tobey74 ,


Yes, you can use the GoToActivity with API and the advantage is that you can specify the FromActivity in order to not stop all other activities but only one.
This API is already used by the very intersting custom service broker Workflow Management:

Warning:  we have encountered a problem with GoToActivity (K2 Five 5.1 to 5.4 at least)
Following the use of the go to activity inside a Split/Merge the workflow stops at the “Merge” step next. Issue appears with Go To Activity from Management site with K2 Five new designer (Split and merge was not possible in K2 Studio).
The issue appears too with Process Version Migration Utility:
At the same time, I asked to an impacted customer to create 2 K2 Ideas created in order to maximize the chances of having actions taken on this subject which can be blocking.
I therefore invite you to vote on these K2 ideas:
Fix issue: after go to activity, the workflow stop at the next merge step.
Add warning message in case of use of Go to activity from Management site to avoid important issue with split branches.
Please vote on them and don't hesitate to transfer to your colleagues who have a K2 account: For a K2 Idea to possibly be considered, you need at least 20 votes.

In addition, a normal behavior to know is the following:
If there are several activities in progress on the same instance of worklfow and that one uses the GoToActivity on any activity,
all the activities are finished and it does not will remain more than that specified by the Go To Activity.
However, it is possible to do a Go To Activity for a specific activity via the API.
This functionality has been implemented in the Workflow Management:
With this tool, we have possiblity to specifiy the "FromActivityName".
SmartObject service tester++ URL (
SmartObject ExplorerDefaultSmoTask_managementMethodsGotoActivity -E ProcInstID=123;FromActivityName=Task1;ActivityName=Task3
Best regards,