Detailed information on the Audit Trail panel

This chapter describes the functions writeAuditEntry and writeAuditBatchEntryas well as the _auditTrail data point type. The functions writeAuditEntry and writeAuditBatchEntry are used to generate the entries for the Audit Trail panel. The functions are included in the scripts/libs/userMan.ctl file. You can get the entries by defining parameters for the above-mentioned functions. The functions and parameters are described in the following: writeAuditEntry()

The function writeAuditEntry is used to write set point values into the Audit trail panel.

Synopsis

writeAuditEntry(anytype dpe, anytype oldvalue, anytype newvalue, int &error, string reason = "");

Synopsis

Parameter Description
dpe The data point element (e.g. string dpe = "threshold_value"). Can also be a dyn_string.
oldvalue One or more values. If the parameter dpe is of type dyn, several values can be written (e.g. float oldValue = 85).
newvalue One or more values. If the parameter dpe is of type dyn, several values can be written (e.g. float newValue = 80).
&error

Returned error code

If the return code is 0 there is no error

If the return code is -1then the dynlen(oldvalue) !==dynlen(newvalue). This means that several values were set at the same time and the number of values does not match.

reason = "" Reason (an arbitrary text) why the value was changed. Default value is empty .

Return value

None

Description

The function is used for set points (e.g. for set point of water level or threshold value for injection molding) and writes the old and new values as well as the reason why the value was changed. The reason is, however, optional and can be left empty. Note that if you want to get the data point configurations (value changes) from PARA into the Audit Trail panel you have to call this function. The values are not written automatically into the Audit Trail panel.

Example

The function writes the used device (dpe) "threshold_value", old value 85 and new value 80 and the reason why the value was changed "Too high temperature at injection molding" into the Audit Trail panel.

main()
{
  string dpe = "threshold_value";
  float oldvalue = 85;
  float newvalue = 80;
  string reason = "Too high temperature at injection molding";
  int error;
  writeAuditEntry(dpe,oldvalue,newvalue,error,reason);
  DebugN(dpe,oldvalue,newvalue,error,reason);
}

writeAuditBatchEntry

The function is used e.g. in production processes and it writes the batch id, the data point element the executed action had an influence on, the data point type, the executed action and the reason why the action was executed.

Synopsis

writeAuditBatchEntry(unsigned batchid, string item, string itemtype, string action, int &error, string reason = "");

Synopsis

Parameter Description
batchid The id number of a process if a process number exists.
item The data point element the executed action had an influence on (e.g. string item = "prod_proc";).
itemtype The data point type. The type is, however, not shown in the Audit trail panel.
action The executed action (e.g.string reason = "Production process started").
&error

The returned error code

If the return code is 0 the error is OK

Error handling is not programmed.

reason = "" Reason why the action was executed. Default value is empty.

Return value

None

Errors

If the return code is 0 the error is OK. Error handling is not programmed.

Description

The function writeAuditBatchEntry is used to write information like batch id, action etc. (see parameters above) into the Audit trail panel.

Example

The function writes the batch ID 4, item (dpe) "prod_proc", action "Production process started" and the reason "Start the production process" into the audit Trail panel.

main()
{ 
  unsigned batchid = 4;
  string item = "prod_proc";
  string itemtype = "proc";
  string action = "Production process started"; 
  int error; 
  string reason = "Start the production process";
  writeAuditBatchEntry(batchid,item,itemtype,action,error,reason);
  DebugN(batchid,item,itemtype,action,reason); 
}

_AuditTrail data point type

The following table shows the structure of the _AuditTrail data point type:

Element Meaning
time Time when the "action" (change of a value) was executed.
username The user name.
uinum The number of the user interface.
batchid The batch ID if the executed action has a batch number.
item The data point element the executed action had an influence on.
itemtype The data point type.
action The executed action.
oldval The old value.
newval The new value.
reason The reason why the value was changed.