AuditLogRecords.NextRecord

Syntax Parameters Return Value
- This function has no parameters. AuditLogRecord

SVB Example

Creating a custom audit log report:

Sub Main

    'This example will create a spreadsheet report of all
    'approved samples since a given start date.

    Dim oOM As ObjectManager

    'Reconnect into Enterprise
    Set oOM = New ObjectManager
    oOM.Reconnect Application

    'Query all the audit logs since Feb. 1, 2017
    Dim records As AuditLogRecords
    Dim startDate As Date
    startDate = 42767 'Julian value, in this case Feb. 1, 2017
    'The last argument to AuditLogRecordsEx is a SQL WHERE clause to filter with.
    'The clause is executed against Enterprise's CSLOG table, which be be
    'reviewed with Statistica Query.
    'In this example, we will filter all sample records that were changed and approved.
    Set records = oOM.AuditLogRecordsEx(True, 5000, swcAscending, 0, startDate, Now(), _
        "ACTN='change' AND OBJTYPE='sample' AND NEWVAL='approved'")

    Dim spr As New Spreadsheet
    spr.SetSize(100000,6)
    Dim currentRow As Long
    currentRow = 1

    'Iterate through the records
    While Not records.IsEOF

        Dim currentAuditLog As AuditLogRecord
        Set currentAuditLog = records.NextRecord()

        'Stop if we are at then end of the returned records
        If records.IsEOF Then
            Exit While
        End If

        'Copy over information from the record into the spreadsheet
        spr.Value(currentRow, 1) = currentAuditLog.ID
        spr.Value(currentRow, 2) = currentAuditLog.OldValue
        spr.Value(currentRow, 3) = currentAuditLog.NewValue
        spr.Value(currentRow, 4) = currentAuditLog.Reason
        spr.Value(currentRow, 5) = currentAuditLog.MiscellaneousData
        spr.Value(currentRow, 6) = currentAuditLog.Time
        currentRow = currentRow + 1
    Wend

    'Format our report spreadsheet
    spr.VariableFormatString(6) = "yyyy-MM-dd HH:mm:ss"
    spr.DeleteCases(currentRow, spr.NumberOfCases)
    spr.VariableName(1) = "ID"
    spr.VariableName(2) = "OLD VALUE"
    spr.VariableName(3) = "NEW VALUE"
    spr.VariableName(4) = "REASON"
    spr.VariableName(5) = "MISC."
    spr.VariableName(6) = "TIMESTAMP"
    spr.AutoFitVariables
    spr.Header.Value = "Sample approvals after Feb. 1, 2017"
    spr.Visible = True

End Sub