Set up Multiple Files
If your database solution is made up of multiple related files, such as in a solution that uses the Data Separation Model, there are a few extra steps that need to be done for CNS Audit to correctly audit your databases.
Make sure all files have a reference to the CNS Audit tables
Every file in the solution will need an external Table Occurrence reference to the three CNS Audit tables, CNS Audit Log, CNS Access Log, and CNS Audit Prefs. It does not matter which file the actual CNS Audit tables are in, and they can even be in a file all by themselves if you want, but every file in the solution needs to have access to them. Also, make sure you do not rename the Table Occurrences.
Modify the CNS Audit Trigger fields
In each of your tables that you have set up for auditing by adding the CNS Audit Timestamp and CNS Audit Trigger fields, you will need to make a small modification to the CNS Audit Trigger calculation.
- Open the Database file and go to Define / Manage Database.
- Switch to the Fields tab and select the first table from the Table drop-down menu in which auditing has been added.
- Select the CNS Audit Trigger field you created when setting up the database for tracking field changes.
- Press Options.
- In the Options for Field dialog that pops-up, switch to the Auto-Enter tab, and click the Specify… button next to the Calculated Value option.
- In the Specify Calculation dialog that pops up, you should see two double quotes as the last parameter to the CNSAudit_RecordChange function.
- Determine if your database will only be used by client versions of FileMaker Pro 11 or above: a. If so, insert the Base Table Name of the table you are modifying between the double quotes. b. If not, insert any Table Occurrence Name of of the table you are modifying between the double quotes. (At the top of the Specify Calculation dialog is the Evaluate this calculation from the context of setting. You can use the same Table Occurrence name in your calculation as is selected in that setting.)
- Press OK to close the Specify Calculation dialog.
- Press OK again to close the Options for Field dialog.
- Repeat steps 3–9 for each table that you have setup for auditing.
- Close the Define / Manage Database dialog.
Modify the Startup scripts
Every file in your solution will need a script that is called when your solution is opened. You can follow the instructions in the Set up the database for startup and shutdown section if you have not already. However, it’s important to note that it’s possible for a database file to be opened without the Startup script being run. This usually happens if FileMaker Pro opens the file to satisfy a relationship from the current file. Because of this, you need to ensure that the main database file for your solution will call the Startup scripts of every other file in your solution.
In the Startup scripts for each of the files, modify the CNSAudit_StartupFile function to include a paragraph-mark delimited list of every file name in the solution. For example, if your solution is made up of three files named Contacts.fmp12, Calendar.fmp12, and Interface.fmp12, then modify the CNSAudit_StartupFile function in each file to look like:
CNSAudit_StartupFile( “Contacts¶Calendar¶Interface” )
Modify any CNSAudit_AccessLog calls
If you are using the CNSAudit_AccessLog function in any scripts or calculations, you will need to update those calls as well. That function also has an optional third parameter like the CNSAudit_RecordChange function. If your database solution will only be used with FileMaker Pro 11+ clients, specify the Base Table Name of the table that is in context for the script or calculation as the third parameter. If your database solution will be used with any version of FileMaker Pro less than version 11, specify any Table Occurrence name of the table that is in context for the script or calculation as the third parameter.
After making the above four changes, your multi-file database solution will be set up for auditing with the CNS Audit plug-in.