Skip to main content
do you need administrator privileges on a process to be able to set data fields via c# code?
If you are setting the data fields after calling CreateProcessInstance (your subject is "start a process instance" so I thought that might be a possibility) then No you don't need process admin; you only need 'Start' permissions.  If you are using the OpenProcessInstance method of the SourceCode.Workflow.Client then yes, as of version 0807, you need process admin permissions.

Just a note that in 0807, when updating process data from client pages, you should not use the ProcessInstance.Update() method.  Due to the change in 0807 mentioned by Bob, this call needs Process Admin rights.  The proper way to update the data from the client page to the process is to use an update Action.  If you have access to the KB, you can refer to KB000307.

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