Audit

Set Audit Fields on Insert

Description
This customization shows how to implement an audit trail by creating and modifying audit fields in a database record.
Variables
Table Name
Select the name of the database table
Audit Field
Select an audit field in the table
Applies to
RecordClass class
Code
 
''' 
''' This custom method is an event handler for the insert event in the Data Access Layer.
''' 
Private Sub Audit_Insert(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _
    Handles MyBase.InsertingRecord    
	''' You can modify the following sample code to fit specific need
	   
    'Dim s As String 
    's = Trim(Me.${Audit Field} & vbCrLf & "Inserted by: " & BaseClasses.Utils.SecurityControls.GetCurrentUserName() & " on " & DateTime.Now.ToString() & ".")
        
    'Me.${Audit Field} = s
    
    'Set values of other fields.
    'me.UserName= "loggedInUser"    
End Sub
     

Terms of Service Privacy Statement