Retrieving datafied values

  • 14 March 2007
  • 3 replies
  • 2 views

Badge +1
Hi, I'm (still) new to K2. I just want to retrieve a datafield value and do something based on the value returned.
Am I on the right path? When this code is executed, the error is that the user does not have permission to open a process instance. Thanks in advance.
SourceCode.K2ROM.Connection k2Conn = new SourceCode.K2ROM.Connection();
k2Conn.Open("myServer");

int processInstanceId = //the process instance id;
SourceCode.K2ROM.ProcessInstance pi = k2Conn.OpenProcessInstance(processInstanceId);

foreach (SourceCode.K2ROM.DataField df in pi.DataFields)
{
if (df.Name == "EvalStd1Subjective" && df.Value.ToString()==string.Empty)
{
//do something
}


}

3 replies

Badge +11
In order to open a process instance through the 'OpenProcessInstance' method call, the user needs to have 'Admin' permissions on the process in K2.net Service Manager.

HTH,
Ockert
Badge +1
Thanks. Is there a way to iterate throught the values of a process instance using the credentials of a standard user? As outlined in the pseudo code below, I just need to retrieve the value of a datafield in order to execute some code. Thanks again.
Badge +11
To use the creds of a standard user, you'll need to open the K2ROM connection with the k2Conn.Open("myServer", "ConnectionString") method. Where the connection string contains the [Domain],[Username] and [Password] of the specific user. Then this user will obviously need to have Admin permissions on the process.
Please refer to the Help file for the correct format of the connection string.

Regards,
Ockert

Reply