k2 Approval from web aspx

  • 18 October 2010
  • 1 reply
  • 0 views

Badge +3

i have function like this


private void k2action(int action)
        {
            try
            {
                oConn = new WF.Connection();
                oConn.Open(ConfigurationManager.AppSettings["K2Server"], string.Format("{0},{1},{2}",
                               ConfigurationManager.AppSettings["domain"], ConfigurationManager.AppSettings["username"],
                              ConfigurationManager.AppSettings["password"]));


                WF.WorklistItem wfItem = oConn.OpenWorklistItem(Request.Params["sn"],"ASP");
                oConn.ImpersonateUser(user);
                wfItem.Actions[action].Execute();
            }
            finally
            {
                if (oConn != null)
                    oConn.Close();
            }
        }


 


it get an error in wfItem.Actions[action].Execute(); and it say it was null and Object reference not set to an instance of an object.


 


can anyone help me here??


when i debug it and check the worklist item, the folio and serial number is correct when i check it but the action count is 0


oyeah i can approve it via k2 workspace though


 


thx


1 reply

Badge +5

Hi There,


I see that in your code you are using impersonation, in this case the impersonation call should be made before the openworklist call. Have a look in the K2 help file under ' K2 Developer Reference->Accessing-> how to retrieve the worklist of a suer and open worklist item' for a full code sample.


 


I hope this helps

Reply