Platform SDK: Exchange 2000 Server

AddEntry Method

[This is preliminary documentation and subject to change.]

Add entry to audit trail.

[Visual Basic,VBScript]
Sub AddEntry( bsDescription As String,
              [hResult As Long],
              [eEvent As CdoWfAuditTrailEvents = cdowfATECustom],
              [varStateChangeInfo] )
[C++]
HRESULT AddEntry(BSTR bsDescription,
                     long hResult,
                     CdoWfAuditTrailEvents eEvent,
                     VARIANT varStateChangeInfo);

[IDL]
HRESULT AddEntry( [in]BSTR bsDescription,
                    [in, defaultvalue(0)]long hResult,
                    [in, defaultvalue(cdowfATECustom)]CdoWfAuditTrailEvents eEvent,
                    [in, optional]VARIANT varStateChangeInfo);

Remarks

You use AddEntry() to log event information to the configured AuditTrailProvider which can be one of three sample providers supplied with Workflow for Microsoft® Exchange 2000 Server, or one you wrote yourself.

The workflow engine calls AddEntry() in cases of state change or transition failures. AddEntry() can also be called from script using WorkflowSession.AuditTrail.AddEntry. Such entries are called custom entries.

The last parameter of AddEntry(), varStateChangeInfo, can be either empty or an array of strings that describe the state change information. In C++ it can be either an empty VARIANT or a VARIANT containing a SAFEARRAY of 5 BSTR. In Microsoft® Visual Basic® it can be either omitted or contain an array of 5 Strings. Here are what the five strings represent in order:

  1. New State
  2. Old State
  3. Caption
    1. Event Type
    2. ID

Note   eEvent and varStateChangeInfo parameters are reserved for the Workflow engine and should not be changed by workflow authors.

Example

The following example illustrates the use of the IWorkflowSession AddAuditEntry method which uses the IAuditTrail AddEntry method. The example code writes affirmative messages to the audit trail that help the developer to trace the progress of the code. This is useful in debugging a workflow application.

Using the AddAuditEntry method is the preferred way to log messages for most typical application developers. Normally, you won't use the AddEntry method directly, unless you are implementing your own audit trail provider.

[Visual Basic]
Sub AddProp()

WorkflowSession.TrackingTable.MoveFirst

For i = 0 to WorkflowSession.TrackingTable.RecordCount-1 Step 1

   if WorkflowSession.Sender = WorkflowSession.TrackingTable.Fields("email").value then
      WorkflowSession.AddAuditEntry "email address matched"

      if "A"=WorkflowSession.TrackingTable.Fields("state").value then 
         'the state value here is hard coded you will have to 
         'change this for your own action table
         WorkflowSession.AddAuditEntry "state matched"

         WorkflowSession.TrackingTable.Fields.Item("custom0").Value= WorkflowSession.ReceivedMessage.Fields("Amount").value

         WorkflowSession.AddAuditEntry "added the value to the customfield"
         WorkflowSession.TrackingTable.Update
      End if
   End if
   WorkflowSession.TrackingTable.MoveNext
Next
WorkflowSession.DeleteReceivedMessage

End Sub

See Also

IAuditTrail Interface

AuditTrailEventLog

AuditTrailPropPI

AuditTrailPropWF

IProcessDefinition