Add datafield to running workflow.


Badge +7

How would I add a  datafield to an already running workflow?   

 

I saw an answer earlier which was like..

 

SCConnectionStringBuilder hostServerConnectionString = new SCConnectionStringBuilder();
hostServerConnectionString.Host = "k2.debtcutter.com.au";
hostServerConnectionString.Port = 5555;
hostServerConnectionString.IsPrimaryLogin = true;
hostServerConnectionString.Integrated = true;

SourceCode.Workflow.Client.Connection K2Conn = new SourceCode.Workflow.Client.Connection();
K2Conn.Open("k2.debtcutter.com.au");

// Replace this with your Process Instance ID
int iProcInstID = 41;
SourceCode.Workflow.Client.ProcessInstance K2PI = K2Conn.OpenProcessInstance(iProcInstID);


K2PI.DataFields["ClientComments"].Value = "";
K2PI.Add();

 

 

but the K2PI does not have the ADD method.

 

Oh man I done goofed and this is now in production :(

 


2 replies

Userlevel 1
Badge +8

You won't be able to add a field to a deployed workflow. What you can do is update your workflow with the missing datafield, deploy the new workflow and then use the LIM (Live Instance Migration) API to migrate running workflows to the new version.

 

Given the custom nature of how LIM is used is based on scenario, there isn't a GUI for it as each implementation has to be crafted. In your case, you will most likely need to set the process data field with the value since it will be a new addition and wouldn't have a value in the old running instances where it was absent.

 

Here is a starting point to learn about LIM: http://help.k2.com/onlinehelp/k2blackpearl/devref/4.6.11/default.htm#Live_Instance_Management.html%3FTocPath%3DRuntime%2520APIs%2520and%2520Services%7CWorkflow%7CWorkflow%2520Management%2520API%7CLive%2520Instance%2520Management%2520(LIM)%7C_____0

 

Here is an article that also pulls a few resources together: http://community.k2.com/t5/K2-blackpearl/How-to-migrate-existing-process-instances-to-a-new-version-of/ta-p/90422

 

Hope this helps get you started.

 

S.

Badge +7

Thank you again Scot,  you are awesome! 

Reply