Error when executing connection.OpenWorklistItem(worklistItem.SerialNumber); method!

  • 26 January 2011
  • 1 reply
  • 7 views

Badge +2

Good day mates,


Hope you all doing well!


I just started migrating from K2.NET 2003 to K2 Blackpearl. Using K2 API's just tried to generate my worklist calling the below method in Page Load event.


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 



public



 



 


void

generateWorklist()

{



 



 


//Specify the connection details based on those found in the environment



 



 


string serverName = "JPCVIRPIMS3"

;

 



 


string user = "JPCPIMS"

;

 



 


string domain = "JHBPROP"

;

 



 


string password = "4Blueturtle@123"

;

 



 


string folioName = ""

;

 



 


//User used to log on to the K2 server must have impersonate rights if impersonation is to be used



SourceCode.Hosting.Client.BaseAPI.



 


SCConnectionStringBuilder newK2Connection = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder

();

newK2Connection.Authenticate =



 


true

;

newK2Connection.Host =



 


"JPCVIRPIMS3"

;

newK2Connection.Integrated =



 


true

;

newK2Connection.IsPrimaryLogin =



 


true

;

newK2Connection.Port = 5555;


newK2Connection.UserID = user;


newK2Connection.WindowsDomain = domain;


newK2Connection.Password = password;



newK2Connection.SecurityLabelName =



 


"K2";

//the default label



 



 


//Opening a connection to the K2 server



 



 


Connection connection = new Connection

();

connection.Open(serverName);


 



 



 


// write current username to console



Response.Write(



 


"Current logged in user: " + connection.User.Name + "<br/><br/>"

);

 



 


try



{



 



 


//connection.ImpersonateUser("k2democarolm"); //The user specified above for the connection will impersonate this user



Response.Write(



 


"This worklist belongs to: " + connection.User.Name + "<br/><br/>"

);

Response.Write(



 


"<table width = '100%' border = '1'>"

);

Response.Write(



 


"<tr bgcolor = 'gray'>"

);

 



Response.Write(



 


"<td>Process Name</td><td>Activity Name</td><td>Original Destination</td><td>Process Folio</td><td>Status</td><td>Serial Number</td><td>Open Item</td>"

);

Response.Write(



 


"</tr>"

);

SourceCode.Workflow.Client.



 


WorklistCriteria wlc = new SourceCode.Workflow.Client.WorklistCriteria

();

 



 


//int n = connection.OpenWorklist(wlc).Count;



 



 


// loop through each worklist item



 



 


foreach (SourceCode.Workflow.Client.WorklistItem worklistItem in

connection.OpenWorklist(wlc))

{



 



 


// open the worklist item



connection.OpenWorklistItem(worklistItem.SerialNumber);



 



 


if (worklistItem != null

)

{



 



 


// retrieve properties of worklist item



Response.Write(



 


"<tr>"

);

Response.Write(



 


"<td>" + worklistItem.ProcessInstance.Name + "</td>"

);

Response.Write(



 


"<td>" + worklistItem.ActivityInstanceDestination.Name + "</td>"

);

Response.Write(



 


"<td>" + worklistItem.AllocatedUser + "</td>"

);

 



 


if (worklistItem.ProcessInstance.Folio == ""

)

{



folioName =



 


"Folio not assigned"

;

}



 



 


else



{


folioName = worklistItem.ProcessInstance.Folio;


}



 



 


//Column displaying worlist item folio name



Response.Write(



 


"<td>" + folioName + "</td>"

);

 



 


//Column displaying worklist item status



Response.Write(



 


"<td>" + worklistItem.Status + "</td>"

);

 



 


//Column displaying worklist item serial number



Response.Write(



 


"<td>" + worklistItem.SerialNumber + "</td>"

);

 



 


//Column containing link to relevant worklist item client page



Response.Write(



 


"<td><a href = '" + worklistItem.Data.ToString() + "'>Click Here</a></td>"

);

Response.Write(



 


"</tr>"

);

}


}



Response.Write(



 


"</table>"

);

Response.Write(



 


"<br/>"

);

connection.RevertUser();


}



 



 


catch (Exception

ex)

{



Response.Write(



 


"Error: "

+ ex.Message);

}



 



 


finally



{


connection.Close();


}


}




I get the below exception


[ClientException] = {"26030 Worklist item 2_59 not found for K2:DOMAIN1KalyanB at 192.0.0.1:51"}


Please someone kindly assist me in this regard. Thanks a lot in advance.


Regards


Kalyan



1 reply

Badge +2


I don't think the code was pasted properly... missing some bits :)


Appart from that, the error is what it says, you probably don't have permissions on that worklistitem to open it.


 




 


Good day Ruben,


Thank you very much for your reply.


I didnt paste my code properly, but now I did.


When I see in the K2 Workspace, I was one of the desination users for that case. And I have full process rights(Admin,Start, View etc..). Still struggling with the same error.


[ClientException] = {"26030 Worklist item 2_59 not found for K2:DOMAIN1kalyanb at 192.0.0.1:54"}


Thanks and Regards


Kalyan

Reply