This sample code shows how to audit user access.
See How to run samples for information about how to run this sample.
This sample first enables user access auditing with the logged on user's organization. Next, it creates and modifies an account table so that audit records are generated.
In order to simulate the scenario described in What this sample does, the sample will do the following:
- Checks for the current version of the org.
- Creates a new account table and enables auditing on the new account table.
- Gets the organization's ID from the system user record and retrieves organization record.
- Enables auditing on the organization, including auditing for user access.
- Makes an update request ti the account table to be tracked by auditing.
- set the organization and account auditing flags back to old values and retrieve them if they were actually changed.
Display an option to delete the records created during Setup. The deletion is optional in case you want to examine the entities and data created by the sample. You can manually delete the records to achieve the same result.