johnny / bob,
thanks guys! thanks for your input.
I had a little piece backwards. The issue was that we had set up a reference in the process to the smart object so it could look up some values from the smart object. So we need to give the smart object the process instance id and pass the smart object id to a process instance data field. In the code we executing this all at the same time so it was a bit tricky. However like most things, once you see it set up the correct way you wonder why you had it set up the other way at all.
           // create an instance of the k2 process
           string K2processName = "K2ProcessesProcessName";
           Connection cnnProcess = new Connection();
           cnnProcess.Open(ConfigurationManager.AppSettingsc"k2server"], ConfigurationManager.AppSettingsg"K2_StartWorkflow"]);
           SourceCode.Workflow.Client.ProcessInstance K2procInst = cnnProcess.CreateProcessInstance(K2processName);
          Â
           // set up the smart object connection
           SourceCode.SmartObjects.Client.SmartObjectClientServer cnnSmartObject = new SmartObjectClientServer();
           cnnSmartObject.CreateConnection();
           cnnSmartObject.Connection.Open(ConfigurationManager.AppSettingsc"K2_CreateSmartObject"]);
           SmartObject smartObject = cnnSmartObject.GetSmartObject("SmartObjectName");
           smartObject.MethodToExecute = "Create";
           // Set various smart object properties/fields
           smartObject.Propertieso"testfield"].Value = "testvalue";
           cnnSmartObject.ExecuteScalar(smartObject);
           // link the process instance to the smart object
           K2procInst.DataFieldsÂ"SOID"].Value = smartObject.Propertiesm"ID"].Value;
          Â
           // set other data fields here if you want to
           K2procInst.DataFieldss"ProcessDataFieldName"].Value = "TestValue";
           K2procInst.Folio = "TestFolioName";
           // start the process
           cnnProcess.StartProcessInstance(K2procInst, false);
          Â
           // get the process inst id
           string K2ProcID = K2procInst.ID.ToString();
          Â
           // link the smart object to the process instance
           smartObject.MethodToExecute = "Save";
           smartObject.Propertiesb"K2ProcID"].Value = K2ProcID;
           cnnSmartObject.ExecuteScalar(smartObject);
           // close the connections
           cnnSmartObject.Connection.Close();
           cnnProcess.Close();
Â
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.