Redirect Worklist Item

  • 6 February 2014
  • 6 replies
  • 16 views

Badge +1

Hi.  First time poster here!


 


I'm working on a project where an admin using a process instance list would redirect a process instance from a role to a specific user in the role.  I'm using the K2Underground "Worklist Service Broker" that has the features of both "Redirect Worklist Item" and "Redirect Managed User Worklist Item".  I've used both. 


 


The issues are:


1) the admin who is doing it can't assign to him/herself if he/she is in the role. 


2)[More important] Once assigned(to someone other than the admin), it won't be in the admin's worklist items assigned to them(which is good), but it will stay in everyone else's list.  It should only be in the person it was assigned. 


 


Here's  an example:


The process instance is assigned to K2 Role "ABC".


ABC has users: UserA, UserB, UserC, UserD.


 


The admin happens to be UserA.


When admin(UserA) redirects the process instance to UserC, this is the outcome:


 


Not in UserA's worklist items.


Still in UserB,UserC,and UserD's worklist items.


 


What should happen: Only in UserC's worklist items.


 



Please help!


6 replies

Badge +3

You don't have to use the custom worklist broker. You can use the standard out of the box API calls.


Using the following signiture


bool WorkflowManagementServer.RedirectWorklistItem(string fromUserName,string toUserName,int procInstID,int actInstDestID,int worklistID)


 


Please see below for a code example:


            WorkflowManagementServer wfManServ = new WorkflowManagementServer();


            try


            {


                // Create a new connection


                wfManServ.CreateConnection();


                // Open the connection


                wfManServ.Connection.Open("Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=localhost;Port=5555");


 


                foreach (SourceCode.Workflow.Management.WorklistItem worklistItem in wfManServ.GetWorklistItems("", "", "", "", "", "", ""))


                {


                    if(worklistItem .ProcInstID.ToString() == txtProcessInstanceID.Text)


                        wfManServ.RedirectWorklistItem("denallixCarl", "denallixBob", worklistItem.ProcInstID, worklistItem.ActInstDestID, worklistItem.ID);


                  }


            }


            finally


            {


                if (wfManServ != null)


                {


                    if (wfManServ.Connection.IsConnected)


                        wfManServ.Connection.Close();


                    wfManServ.Connection.Dispose();


                }


                wfManServ = null;


            }


 


 

Badge +1

Thank you so much for the quick response!


 


Is there no way to do what I was referring to without using code?  Have I just configured some of the options wrong(slots, destination roles, etc)?


 


My preference is to use as much prebuilt things from smartforms, workflows, etc as possible before pursuing the coding route.


 


Thanks again.  I really appreciate your response.

Badge +3

The way that I was able to get the slot ID was to create a stored procedure in the K2 DB as per below:


->Once the stored procedure is created then create a SmartObject on this Stored procedure


-> Create a stored procedure on [Server].[kWorklistItemRedirect] which needs a slotID and who to direct to


-> Once these two SmartObjects are created you should be able to use the Smart Objects to redirect users.


 


USE [K2]


GO


/****** Object:  StoredProcedure [Server].[kWorklistItemItems]    Script Date: 2/7/2014 7:01:34 AM ******/


SET ANSI_NULLS ON


GO


SET QUOTED_IDENTIFIER ON


GO


/*


*/


CREATE PROCEDURE [Server].[kWorklistItemItems]


AS BEGIN


 


SET NOCOUNT ON;


 


/*


Status:


0 = Available


1 = Open


2 = Allocated


 


Return:


1 = Worklist item not found


2 = Item not open


3 = Success


*/


 


 


SELECT


[WS].[ProcInstID],


[WS].[ActInstID],


[WS].[Status],


CONVERT(INT, ISNULL([WS].[SlotFieldID], 0)) AS SlotID,


[EV].[Name],


.Type


FROM


[Server].[WorklistSlot] AS [WS] WITH (NOLOCK)


INNER JOIN [Server].[WorklistHeader] AS [WH] WITH (NOLOCK)


ON [WH].[ProcInstID] = [WS].[ProcInstID]


AND [WH].[ID] = [WS].[HeaderID]


INNER JOIN [Server].[Act] AS WITH (NOLOCK)


ON .[ID] = [WH].[ActID]


INNER JOIN [Server].[Event] AS [EV] WITH (NOLOCK)


ON [EV].[ID] = [WH].[EventID]




END


 


 


Please keep in mind this is my own opinion and is not the only way.


I am also not suggesting that this is a best practice.


 


 


The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.

Badge +3

I meant that you must create a SmartObject on the existing stored procedure [Server].[kWorklistItemRedirect]


The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.

Badge +1

Ah.  OK. 


 


So with these two stored procs(one already in K2), I'll be able to redirect a worklist item to someone and it will be out of everyone's worklist items list, which it was there originally because it was assigned to a role which they were in. 


 


Thanks so much!


Thanh

Badge +1

DarrynH,


 


I looked over the stored proc you wanted me to make and had a question:


Why does it need to join with the WorklistHeader, Server.Act, and Server.Event?


Server.WorklistSlot seems to have what I would need: procinstID, slotID, actInstID.


It looks like  you're returning the [Ev].Name and .Type.  What are these being used for?  

Reply