How to end a workflow or go to current activity via existing smart objects?

  • 22 March 2016
  • 2 replies
  • 4 views

Badge +1

Hello, 

 

I need two buttons on a form. One of them is for ending workflow and other one is for going to current activity.

 

Is there any smart objects that provide that? 

 

When i searched this in the community, i found that.

http://community.k2.com/t5/K2-Appit/Ending-an-active-workflow-via-form-button-or-workflow-event/ta-p/83777

 

But these smartobjects that are told about don't exist in the system. Do you know, how can i  find them? 

Or are there another smartobjects that provide this need?

 

Thanks


2 replies

Badge +10

There are no out of the box SmartObjects that provide that functionality. Its custom development that we've done for some of our customers.  You'd need to create a custom service object that utilitizes the K2 Management APIs and then create a SmartObjects against that custom service object you created. 

 

K2 BLACKPEARL PRODUCT DOCUMENTATION: DEVELOPER REFERENCE

http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.11/default.htm

Badge +10
public static string GoToActivity(int processInstanceId, string activity)
{
string result = String.Empty;

try
{
wms = OpenWmsConnection();
wms.GotoActivity(processInstanceId, activity);

result = "SUCCESS";
}
catch (Exception ex)
{
result = "FAILURE: " + ex.Message;
}
finally
{
wms.Connection.Close();
wms.Connection.Dispose();
}

return result;
}

private static WMS.WorkflowManagementServer OpenWmsConnection()
{
var wms = new WMS.WorkflowManagementServer(//pass your details here);
try
{
wms.Open();
}
catch (Exception ex)
{
}
return wms;
}

Above is a custom method I wrote and exposed as a smartobject method. You pass in the activity where you want to go and the processinstanceid and it does the rest. I have removed some stuff thats not related but the above should work for you. Hope that helps

Reply