Adding datafield to running process


Badge +10

Hi guys,

 

I have a scenerio where I have to make changes to a production workflow. The changes I have made require adding additional datafields that will be used by the forms. Since there is no forms and smartobject versioning ad only workflow versioning is it possible to programatically add datafields to a already runnig workflow.

 

Thanks   


6 replies

Badge +5

Hi, sOm3one


 


Please see see the following links before attempting the code below:


 



I think is in the same way as updating a data field, just change Update() and call Save() or Add()


At the end is worth trying.


 


Please try the following code sample below:


 


SourceCode.Workflow.Client.Connection K2Conn = new SourceCode.Workflow.Client.Connection();


K2Conn.Open("localhost");


 


// Replace this with your Process Instance ID


int iProcInstID = 41;


SourceCode.Workflow.Client.ProcessInstance K2PI = K2Conn.OpenProcessInstance(iProcInstID);


 


K2PI.DataFields["Last User"].Value = "New Val";


K2PI.Add();


 


Just remember that the app pool account executing this code needs Admin permissions on the Process.

 

Regards

 

Julia
Badge +5

Hi, s0m3one


 


Please see K2 blackpearl developer reference links below:


 



 


Regards


 


Julia

Badge +5

Hi, s0m3one


 


To follow up on this post did any of the above suggestions help you  with Adding datafield to running process?


Can you please update us with regards to this post.


 


Regards


 


Julia

Badge +10

Sorry for the late reply. Thank you very much for your help Julia. I have an additional issue that i have run into. I wonder if you could help me with that aswell. I have a smartobject event in a visual studio K2 workflow, where it calls a smartobject and writes two output properties of the smartobject to two datafields. Now, I have added two extra properties to the return peroperties of  this smartobject method. When I did that the older workflows always failed at this step with a "Item not found in this collection" error. I have fixed the error by refreshing the smarobject output properties but this only works in the newer workflows after the refresh. The old workflows still fail at thsi step. This is not a major issue since I can always jump the workflow and populate the data fields through code but just wondering if you knew of a better way.

 

Thanks

Badge +5

Hi, s0m3one


 


This error can occur if the smartobject service method does not return the same properties as that of input properties.


Just make sure that the smartobject service method return same properties as that of input properties.


 


For more infomation regarding this type of error, please see the links below:


 



 


Kind Regards


 


Julia

Badge +10

Hi Julia,

 

I shouldve told you that this smartobject is built on top of a custom service object and the input and output properties were never matched. Infact the input and output properties are completely different.

 

Thanks

Reply