Skip to main content


 

Symptoms


Issue with using gotoActivity
 

Diagnoses


Hi,

We have a requirement to enable cancel workflow for the originator through the smart forms so that the originator can cancel the workflow at any point of time. Based on our analysis, we were trying to use the GoToActivity() method as follows :

private void goToActivity(int procinstid, string ActivityName)
{
System.Diagnostics.EventLog EventLog = new System.Diagnostics.EventLog()

((ISupportInitialize)EventLog).BeginInit()
if (!EventLog.SourceExists("K2 Custom Goto"))
{
EventLog.CreateEventSource("K2 Custom Goto", "Application")
}
((ISupportInitialize)EventLog).EndInit()
EventLog.Source = "K2 Custom Goto"
EventLog.Log = "Application"
if(this.Service.ServiceConfiguration.ServiceAuthentication.AuthenticationMode == AuthenticationMode.ServiceAccount)
System.Threading.Thread.CurrentPrincipal = null
string ConnectionString = this.Service.ServiceConfigurationo"ConnectionString"].ToString()
WorkflowManagementServer wms = new WorkflowManagementServer()
wms.CreateConnection()
wms.Connection.Open(ConnectionString)
EventLog.WriteEntry("Before calling goto in proc id:" procinstid, EventLogEntryType.Information)
//wms.DeleteProcessInstances(procinstid, false)
wms.GotoActivity(Convert.ToInt32(procinstid),"Finish Workflow")

EventLog.WriteEntry("After calling goto in procid:" procinstid, EventLogEntryType.Information)
wms.Connection.Close()
}

However, the workflow keeps hanging ( running) at wms.GotoActivity(Convert.ToInt32(procinstid),"Finish Workflow") . Finish workflow is our end step in the workflow and I have used procinstid directly as well without any use.

We would like to know what we are doing wrong. Any help would be extremely useful as its stopping our production roll out
 

Resolution


Problem appears to occur when attempting to use Management API (via an SMO) to perform a Goto that expires an Instance , from an event within that same Instance . Race condition occurs where the Event that performs the Goto completes the Instance , but then tries to return back to itself , but seeing as the instance has expired , it gets stuck . Suggestion was to ship the Cancel logic out to a different Workflow and call it via an IPC . This seems to be working




 
Be the first to reply!

Reply