I am trying to update just the process instance data for a given worklist item. There is some .Net 2.0 code that looks for incoming e-mails, processes them, and adds to the journal of the worklist item, but it does this all to a database and not to K2. So, since there aren't any calls to K2, I was curious how to update it without advancing K2 to another Activity? Here is the code that I'm trying to use, but it currently doesn't work, it fails at process.CurrentWorklistItem.ProcessInstance.DataFields....
//***********************************
string _k2ServerName = "MTRAN-SHARE02";
string _k2ProcessName = "MTSSupportTicket";
WorklistItem _k2WorklistItem;
Connection _k2Connection = new Connection();
_k2Connection.Open(_k2ServerName);
ProcessInstance _k2ProcessInstance = _k2Connection.CreateProcessInstance(_k2ProcessName);
ProcessDataFields _processDataFields = new ProcessDataFields();
try
{
WorklistCriteria worklistCriteria = new WorklistCriteria();
worklistCriteria.AddFilterField(WCField.ProcessID, WCCompare.Equal, supportTicket.K2ProcessId);
Worklist worklist = _k2Connection.OpenWorklist(worklistCriteria);
if (worklist.Count == 1)
{
// we should have just one task
_k2WorklistItem = worklist[0];
_k2ProcessInstance = _k2WorklistItem.ProcessInstance;
}
}
catch
{
}
_processDataFields.Clear();
foreach (DataField df in _k2ProcessInstance.DataFields)
{
try
{
_processDataFields.Add((SupportTicketData)Enum.Parse(typeof(SupportTicketData), df.Name, true), df.Value);
}
catch (Exception) { }
}
SupportTicketProcess process = new SupportTicketProcess(_k2ServerName, _k2ProcessName);
process.OpenNextWorklistItem(supportTicket.K2ProcessId);
supportTicket.StatusDescription = "User Feedback Received";
process.CurrentWorklistItem.ProcessInstance.DataFields[SupportTicketData.StatusDescription] = supportTicket.StatusDescription.ToString();
supportTicket.StatusDescription.ToString();
process.CurrentWorklistItem.Update();
//***********************************/
Update Process Instance Data Only
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
