Skip to main content

Hi All,

 I'm developing a outside program (webservice) that will be able to update values on running process datafields, currently it can start/stop processes, goto activity, and update process datafields, but we need to be able to update datafields inside a activity of a process (activity datafields).


Francly i have looked and tried several examples, using SourceCode.WorkFlow.Management ] or SourceCode.WorkFlow.Client ] components, but to no avail


SourceCode.WorkFlow.Client classes from what i could tell only updates stuff running with the executing user, and since the program (webservice) runs with a special account that has no processes what so ever it fails


SourceCode.WorkFlow.Management classes i can list the activities using WorkListItems but the object class cannot update the datafields


I could publish code here, but i think my code does very little, what i would apreciate a LOT !!! would be if someone could publish code that runs ouside of K2 (example a webmethod, or c# program, etc) that can connect to a k2 server and update a activity datafield of another user


 


Miguel


 

Try the following:



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.DataFieldsd"Last User"].Value = "New Val";


K2PI.Update();



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


Thankx DC, but that code update a PROCESS DATAFIELD, that i have already and it's "easy" but what i need is to update a ACTIVITY datafield


Building on DC's example have you tried:


K2PI.ActivityInstancess"My Activity"].DataFieldss"My Data Field"].Value="Hello";


Hi Timkc


 


 That would be great but no, there is no such method available for the K2PI object, among several options i can change the datafields and xml fields of the process but no reference to activityinstances is available !


 


Notice i'm using K2 BlackPerl


 


Miguel


You're right.  I should have tested outside of a K2 Process before posting :<.


I looked at some other options like the K2 Services but didn't see anything that appear to directly do what you wanted to do.  One option that may or may not work for your situation is to use DC's post to update a "temp" process datafield and have data events in the activities that would then copy the data from the temp process datafields to the activity level.  Not a great workaround and hopefully someone else will post a better solution.


Thankx timks, that might sound great for NEW processes, but the code is required to manipolate running processes no code change was supose to happen on the processes by them selfs, this is supose to be a extension to the running code...


 


so basicly i'm Screwed...


 


I have posted a K2 Support Request and i'm waiting for the aswer... still... if any solution is found by them i will post it here


 


But huge thanks Timks !!


Miguel Angelo




Hi guys


I have the same problem. Is there any solution to this? And does it really mean that I need to apply a workaround by putting all variables into process scope.


 


Thanks.


Hi guys,


I have the same problem. I want to update the Activity Data fields and Activity XML fields.


Please let me know if anyone got the solution to this problem.


Thanks,


Aman


Hi All,


I also want to update the Activity Data and XML. Please let me know if anyone has any solution for this.


Thanks,


Aman


Reply