< class="prominent-subhead ">

Setting the audit values during initiation of a K2.net™ process

This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

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";