Getting Datafield Value Of Completed Process


Badge +10

Hi,

 

I want to get the datafield values of a completed process. I found a similar post and that pointed to the out of the box 'Process Data' smartobject. Now, this smartobject works perfect a long as  the user who is running  has admin rights. I would like to execute this smartobject from a fomr and that form can bee accessed by anyone in the domain. Now, when you execute that smartobject from the form it takes the identity of the form user and executes the smartobject with that identity. Now, here is where it fails. If the user is not an admin then it returns nothing. How can make it so that it can run as anyone and still retrun data as I do nt want to give everyone admin rights. Or is there a better way to do this.

 

Thanks in advance


7 replies

Userlevel 5
Badge +18

I believe "View" rights will also allow users to view reporting data.  Perhaps using an AD group and assigning "View" rights?

Badge +10

Thanks for your reply. In the end I wrote a custom method which uses the workflow.client dll and connects to the k2 server opens the process instance and gets the specified datafield value. This turned out to be much faster as well.

 

Badge +10

The custom method worked well in development but now I have put it into test environment its failing to read the datafield values if the process instance has completed. It reads the data fields fine if the processinstance is active.

 

The error I get is something like 

 

1 26023 Process instance 405789 not found for K2:UK est.user1 at 127.0.0.1:134455

 

 

The account executing the code as shown above has admin rights on the server (workspace) and admin rights on the process that it's trying to open. Not sure what else I need. Any advice would be appreciated.

 

Thanks

 

Userlevel 5
Badge +18

It is likely that this error that you are seeing:


 


1 26023 Process instance 405789 not found for K2:UK est.user1 at 127.0.0.1:134455


 


is due to the process instance not being available to the sourcecode.workflow.client api anymore, because it was completed and is not active anymore as you had described.  I believe to open a process instance with the sourcecode.workflow.client api, it will need to be active.


 


Also does this data field change throughout the process?  Do you just wish to know what it is when the process completes?


 


Perhaps going back to the reporting smartobject implementation that you had tried is still possible.  When creating a connection string, instead of using Integrated=true, and then having to give all users admin/view rights; perhaps you can set Integrated=false, and then specify just a single account that would have admin/view rights.


 


As per the connection string options below:


 


https://www.k2.com/onlinehelp/k2blackpearl/devref/current/default.htm#ConnectionStringSamples.htm%3FTocPath%3DConcepts%2520and%2520Development%2520Techniques%7CAuthentication%2520and%2520Connection%2520Strings%7C_____1


 


This way it will always autheticate and execute with just that account.

Badge +10

Thanks for your reply tin,

 

I have had a look at the connection string link and it looks like I am connecting fine with the right credentails. I have the service object running as the service account and as the error message suggest its runnning wiht the right credentails.  I dont think its a permission issue anymore. Like you said, it works fine if the procesinstance is not completed. To answer you questions.

 

Also does this data field change throughout the process? 

-The datafield does not change after its set by a IPC process right at the beginning.

 

Do you just wish to know what it is when the process completes?

-Its a weird scenerio, not sure how to explain it but basically, I have a serial Number 1122_56. When users navigate to a form with this serial number. I take the processinsntance part 1122 and then open this processs instance. This proces instance contains a field called "ParentProcessInstanceId" which I need to retrieve in order to retrieve some data on the form using that "Parent Process InstanceId.

 

Sometimes 1122 can be running (this works) and sometimes it a can be completed. But either way I need to display the data.

 

If workflow client api does not show datafields for completed processes, is there anything else i can read from. I can see it in the database but Im not ken on reading directly from the database because I dont think K2 recommends this and also it involves a lot of permision hassle in my environent.

 

 

Userlevel 5
Badge +18

I assume your original implementation of opening a smartobject connection (with perhaps a static credentials/connection string) and using the "Process Data" SMO does not work anymore?  


 


As that Smartobject seems to return the datafield for a process instance regardless of it being active or completed; and seems to best fit your use case.

Badge +10

HI Tin,

 

I guess that would also be an option. I wanted to avoid that if possible becasue it seems like a long winded process. I would write a service object to run as a certain account and execute the "Process Data" as the service account. I am hoping one of the K2 devs can advise if there are any API's I cna use for this. If not I will have to go that route.

 

Thanks for you help

Reply