Worklist item and destination user ?


Badge +2

 


Hello ,


My question is that how to make sure that the user opening the work list item is the user destination associated with it ? is there a k2 attribute that I can compare for this purpose ... 


the case I am facing that I need to retrieve the actions from the work list item, but they are not being displayed .. even though the work list is delivered to the right user and the user can action the item through workspace ..



Hope the issue is clear ..


Thank you all ..


3 replies

Badge +5

Hi, May I know how are you accessing the work list? Via ASP.NET page?

Badge +2

 


protected void Page_Load(object sender, EventArgs e)


        {


           string strSN = string.Empty;


                // get the serial number from the query string


                if (Request["SN"] != null)


                {


                    strSN = Request["SN"];


                }


 


                if (strSN != String.Empty)


                {


                    // open a K2 connection


                    SourceCode.Workflow.Client.Connection conn = null;


                    conn = new SourceCode.Workflow.Client.Connection();


                    conn.Open("DOMAIN");


 


                    // get this specific task


                    SourceCode.Workflow.Client.WorklistItem wli = conn.OpenWorklistItem(strSN);


                    // get the process object


                    ProcessInstance pi = wli.ProcessInstance;


     


                    if (wli != null)


                    {


                        // k2 Worklist Actions


                        int actionNo = wli.Actions.Count;


 


                        // Declare buttons array


                        System.Web.UI.WebControls.Button[] buttonArray = new System.Web.UI.WebControls.Button[actionNo];


 


                        // Declare Action array


                        string[] actionsArray = new string[actionNo];


                        int index1 = actionNo - 1;


 


                        foreach (SourceCode.Workflow.Client.Action Act in wli.Actions)


                        {


                            actionsArray[index1] = Act.Name;


                            index1--;


                        }


 


                        int index2 = actionNo - 1;


                        for (int i = index2; i >= 0; i--)


                        {


                            buttonArray = new System.Web.UI.WebControls.Button();


                            buttonArray.ID = i.ToString();


                            buttonArray.Text = actionsArray;


                            buttonArray.Click += new System.EventHandler(actionButton);


                            actionButtonsHolder.Controls.Add(buttonArray);


                        }


 }


 


 


protected void actionButton(object sender, EventArgs e)


{


System.Web.UI.WebControls.


Button button = sender as System.Web.UI.WebControls.Button;


string strSN = string.Empty;


// get the serial number


if (Request["SN"] != null)


{


strSN = Request["SN"];


}


if (strSN != String.Empty)


{


// open a K2 connection


SourceCode.Workflow.Client.


Connection conn = null;


conn =


new SourceCode.Workflow.Client.Connection();


conn.Open(


"tfs.ideaslab.com");


// get the worklist item


SourceCode.Workflow.Client.


WorklistItem wli = conn.OpenWorklistItem(strSN);


 


if (wli != null)


{


// set the appropriate action


foreach (SourceCode.Workflow.Client.Action Act in wli.Actions)


{


if (Act.Name == button.Text)


{


Act.Execute();


break;


}


}


button.OnClientClick =


"return false;";


}


//Disable action buttons


foreach (System.Web.UI.WebControls.Button btn in actionButtonsHolder.Controls.OfType


<System.Web.UI.WebControls.


Button>())


btn.Enabled =


false;


// close the connection


conn.Close();


}


 


 

Badge +13

This API should fail OpenWorklistItem if it's opened by someone not assigned to the SN.

Reply