Open Worklist Item without knowing Serial Number

  • 7 January 2008
  • 3 replies
  • 3 views

Badge +1

Hi,


Here is my scenario:


User A creates an location change request with a list of approvers (eg. B & C). The RequestID is saved in database and a datafield "RequestIDField" in the process instance. Obviously B can open the request by following the link in the email sent to him (with Serial Number attached). But what if he wants to open the request by passing the RequestID as a parameter?


I have no way to retrieve the processinstance which has "RequestIDField" = RequestID except looping over all process instances in the K2 server.


Is there any idea to get Process Instance (or Worklist Item) from RequestID and get RequestID from Serial Number?


 Thanks a lot for your help! This is my very critical problem.


3 replies

Badge +8

If you want to open a process instance or a worklist item directly you need the Process Instance ID or Serial Number respectively because these are the only unique identifiers.   Process datafields are not guaranteed to be unique and not every process contains the same datafields so there is no built in API call that can open an item based upon a process datafield.


 To open a worklist item when you only have the datafield and not the serial number you will need to loop through each worklist item for that user's worklist and compare the datafield with the desired value. 


The other option to avoid the looping would be to save the ProcessInstanceID or SerialNumber in the external database with the RequestID field so that you could do something like the following "Select SerialNumber from [TABLE] where RequestID = [Value]" and then use the Serial Number to open the worklist item.


 I hope this helps.


-Eric

Badge +1

Thanks Eric for your reply! I understand the process data field may not be unique and I actually do as what you said in my application. However, I see from K2ROM API that it is possible to search for a WorklistItem in a Worklist based on Criteria. Yet this method is only used for the worklist of current user. What if I want to search my managed users' worklist based on criteria? As far as I know, there is no way to do that. I wonder why K2 doesnt provide this feature.


At this moment, as a manager of several users, I have to loop through all the worklists in order to get a specific worklistitem. This could be a performance issue if the number of my subordinates is large.


 

Badge +8

That is true if the number of suboridates becomes large the search could get bogged down.  My recommendation would be to use an external table that stores SerialNumber/Request ID/username so that then you only have to run a SQL statement that passes in the Request ID and any usernames that you want to search on to get the serial numbers.   Externalizing the data in that way is always going to be faster than anything you could do in the K2ROM or for that matter anything we could build internally because it is built for your specific scenario rather than having to cater for many possible scenarios.


-Eric

Reply