Acessing Data Fields and Processes from Blackpearl API

  • 9 April 2008
  • 3 replies
  • 2 views

Badge +1

Hi


We have written our own worklist frontend in C# and are using the K2 API to retrieve and start tasks. We are able to start tasks correctly. When we come to retrieve tasks using its processID we are able to retrieve the task but the data fields values appear to be null and so throw an exception, the data field names are visable. I have checked in the workspace and the datafields values are populated.


If we get the process from a worklist instead of by a processID then we are then able to view the values of the datafields. The code we are using did work using .net 2003 so i am wondering if the API for retrieving by processId has changed?


The code we are using that works correctly is:


WorklistItem worklistItem = k2Connection.OpenWorklistItem(k2SerialNumber, "ASP", true);


String caseReference = workListItem.ProcessInstance.DataFields["caseReference "].Value.ToString();


The code which returns an error in the value is:


ProcessInstance processInstance = Process.OpenProcess("localhost", processID);


String caseReference = processInstance.DataFields["caseReference "].Value.ToString();


And the error i recieve is:


Message = "Communication error with server
WSASend failed: An operation was attempted on something that is not a socket.
"


Thanks in advance


3 replies

Badge +6

Hi Sean,


Where did you get the "OpenProcess" method? I do not know of any such method in the normal APIs? Is it perhaps OpenProcessInstance rather, but is that in the management API?


Also remember that there is a big difference between ProcessID and ProcessInstanceID - if you are "really" using a ProcessID in that code, then it will not work because it will be the ID of the process definition and will know nothing about the process Instance that you want to get data fields for. Hope that makes sense?


The suggested approach is to use the worklist in the client API (such as in your first example) so if that works I suggest you stick with that. :)


Ciao,


 

Badge +4

The way your post is framed, it sounds like you wrote your c# frontend using the K2.Net 2003 API, or you are at least trying to re-use some of the same codebase from the previous version. If this is the case, you need to download the Developer Reference documentation (just came out a couple of weeks ago) and use some of the many code examples available in there to connect to and use the K2 server. In the documentation there is a section called "About Accessing Processes" which will give you all of the detailed step you'll need in order to access process lists using the [blackpearl] API.


Hope this helps!


endpointsys

Badge +1

HI thanks for this i have managed to retreive the task now and will download the new developer reference.


 


Thanks again.

Reply