When changes are made to the originally submitted data, the process values change to show the new values, and an entry is made in the data audit facility. However, there is no record of what the initial data values were. Read on to find out how to show these initial data values in the audit trail.

When a new process instance is created, the initial data values in the K2.net™ data fields are not included in the audit trail. The audit trail only begins once changes are made to the initial values. To include the initial values in the audit trail, the following must take place in the code when planning a process:
•  Open the K2.net™ 2003 server connection
•  Create the process instance
•  Get the initial values
•  Clear the K2 data fields
•  Start the new process instance
•  Open the process instance
•  Set the data fields again with the original data and update the values
•  Supply the new data and update the K2 data field values again

The code for the above steps is displayed below:

Visual Basic

Dim cn As New SourceCode.K2ROM.Connection
Dim oProc As SourceCode.K2ROM.ProcessInstance


oProc = cn.CreateProcessInstance("K2VB\D-VB-AuditInitialValues ")

‘Use instance default values
Dim strName As String = oProc.DataFields("Name").Value
Dim strEMail As String = oProc.DataFields("Email").Value
Dim strSurname As String = oProc.DataFields("Surname").Value

‘Clean values
oProc.DataFields("Name").Value = ""
oProc.DataFields("Email").Value = ""
oProc.DataFields("Surname").Value = ""


‘Open current instance
oProc = cn.OpenProcessInstance(oProc.ID)

‘Set audit values
oProc.DataFields("Name").Value = strName
oProc.DataFields("Email").Value = strEMail
oProc.DataFields("Surname").Value = strSurname

‘Set actual values
oProc.DataFields("Name").Value = "David”
oProc.DataFields("Email").Value = "david@k2workflow.com"
oProc.DataFields("Surname").Value = "Engelbrecht"
oProc.Folio = "Audit Initial"


SourceCode.K2ROM.Connection cn = new SourceCode.K2ROM.Connection();
SourceCode.K2ROM.ProcessInstance oProc;


oProc = cn.CreateProcessInstance(@"K2CS\D-CS-AuditInitialValues");

//Use instance default values
string strName = oProc.DataFields["Name"].Value.ToString();
string strEMail = oProc.DataFields["Email"].Value.ToString();
string strSurname = oProc.DataFields["Surname"].Value.ToString();

//Clean values
oProc.DataFields["Name"].Value = "";
oProc.DataFields["Email"].Value = "";
oProc.DataFields["Surname"].Value = "";


//Open current instance
oProc = cn.OpenProcessInstance(oProc.ID);

//Set audit values
oProc.DataFields["Name"].Value = strName;
oProc.DataFields["Email"].Value = strEMail;
oProc.DataFields["Surname"].Value = strSurname;

//Set actual values
oProc.DataFields["Name"].Value = "David";
oProc.DataFields["Email"].Value = "david@k2workflow.com";
oProc.DataFields["Surname"].Value = "Engelbrecht";
oProc.Folio = "Audit Initial";