Audit Logs Sample
What you need to know
An application can register its own Event Types and Group Types, which for convenience can be mapped in static entities.
Each Group Type and Event Type should have a unique Id, to make sure it doesn't clash with another event type from a different application. The easiest way to guarantee that is to use UUIDs for each event type. Don't worry, you will only need to define the UUID once in the static entity. You can generate UUIDs at the following web site: .https://www.uuidgenerator.net/guid
Each Group Type should indicate if the audit changes should be saved as JSONs (before and after) or field differences. For this add an attribute in the static entity to store that value. Each Event Type should be related to a Group Type, through a static attribute in the static entity mapping the respective foreing key. 
To generate an audit log with change tracking, you can use either AuditEvent_WithObject or AuditEvent_WithJSON actions. These actions allow to specify a Before and After serialization, to record changes made by a user. The AuditEvent_WithObject receives two objects and automatically serializes them to JSON. The AuditEvent_WithJSON requires the developer to provide the JSON.
The simpler AuditEvent action may be used when there's no need for change tracking.
All audit actions automatically capture user information and date/time information, as well as many other information derived from the application context.
You can list audit logs by querying the entity AuditLog.
How to view this sample
This sample contains 2 group types: ContactAuditsJSON, and ContactAuditsFieldsContactAuditsJSON is used when all audit changes are JSON based and ContactAuditsFields for field differences. You can change how audit logs are  over in the Settings page. This sample contains 2 event types per group type: ViewContact and Save ContactViewContact is logged in the Preparation of ContactDetail, and Save Contact. is triggered in the Save screen action of the same screen. Go to the Contacts list and select a contact, then save the contact with some changes, and at least two audit logs will be generated. Check the Audit Logs screen to view them.
Both event types are defined in the AuditEvents static entity, and registered in the RegisterDXCompliance timer, executed when published.
Additional business information about the logged event is stored in the entity ContactAuditLogExtension. This allows the application to store custom attributes on an audit log, including foreign keys.
Click here to see your activities