We have a process that utilizes a smart object to store its data. The process instance is related to the smart object via a process-wide datafield called "Proc_SOID". The Smart Object is related back to the process instance via a property called "K2ProcID". The smart object is added in the process workflow as a reference with the method set to the use Load method. The input parameter is the autonumber of the smart object ("SOID") and is bound to the datafield ("Proc_SOID"). Both the process and the smart object are created in the code-behind of a asp.net page. The problem is that when I create them, the smart object property "K2ProcID" will not hold the value I feed it. It doens't throw an error - it just doens't update. Here is a sample of the code...
public void GoK2()
{
try
{
// create an instance of the k2 process
string K2processName = "ProcessProcessInstance";
Connection cnnProcess = new Connection();
cnnProcess.Open(ConfigurationManager.AppSettings["k2server"], ConfigurationManager.AppSettings["K2_StartWorkflow"]);
ProcessInstance K2procInst = cnnProcess.CreateProcessInstance(K2processName);
// start the process
cnnProcess.StartProcessInstance(K2procInst, false);
// create an instance of the smart object
SourceCode.SmartObjects.Client.SmartObjectClientServer cnnSmartObject = new SmartObjectClientServer();
cnnSmartObject.CreateConnection();
cnnSmartObject.Connection.Open(ConfigurationManager.AppSettings["K2_CreateSmartObject"]);
SmartObject smartObject = cnnSmartObject.GetSmartObject("ProcessSmartObject");
smartObject.MethodToExecute = "Create";
// set the smart object fields
smartObject.Properties["cct_mem_name"].Value = lblMemberName2.Text;
smartObject.Properties["cct_mem_email"].Value = txtEmail.Text;
cnnSmartObject.ExecuteScalar(smartObject);
// link the process instance to the smart object
K2procInst.DataFields["Proc_SOID"].Value = smartObject.Properties["SOID"].Value;
K2ProcID = K2procInst.ID.ToString();
K2procInst.Update();
cnnProcess.Close();
// link the smart object to the process instance
smartObject.Properties["K2ProcID"].Value = K2ProcID;
cnnSmartObject.ExecuteScalar(smartObject);
cnnSmartObject.Connection.Close();
}
catch (Exception ex)
{
// write error to console
Response.Write("Error: " + ex.Message);
}
}
any thoguhts? Thanks!