It is highly recommended from time-to-time to run the standard Dynamics AX data consistency check found in Basic | Periodic | Consistency check to check system data integrity. This function finds orphan data, validates parameters, and does many other things. But in one of my recent projects, I have noticed that it does not do everything. For example, it does not check the data in the AssetLedgerAccounts table, which holds the set up fixed asset posting profiles.
In this recipe, we will see how we can enhance the standard Dynamics AX consistency check to include more tables in its data integrity validation.
Before we start, we need to create an invalid setup to make sure we can simulate data inconsistency. Open General ledger | Chart of Account Details and create a new ledger account, for instance, 000009:
Open General ledger | Setup | Fixed assets | Posting profiles and specify the new account in the Ledger account field, for example, for any records:
Go back to the Chart of accounts form, and delete the previously created account.
Now, we have a non-existing ledger account in the fixed asset posting settings.
Open the LedgerConsistencyCheck class in AOT, and add the following code to the end of its
run()
:this.kernelCheckTable(tablenum(AssetLedgerAccounts));
Open Basic | Periodic | Consistency check, select General ledger node, and click Execute on the right-hand side:
Now, the message displayed in Infolog tells us that the account is missing in the fixed asset posing settings:
The consistency check in Dynamics AX validates only the predefined list of tables for each module. The system contains a number of classes derived from SysConsistencyCheck. For example, the CustConsistencyCheck class is responsible for validating the Accounts receivable module, LedgerConsistencyCheck—for General ledger and so on. Each class performs a check for the tables defined in its run()
.In this recipe, we include the AssetLedgerAccounts table into the latter class, that is, LedgerConsistencyCheck. AssetLedgerAccounts table is where fixed asset posting settings are stored and in this way, we ensure that the settings are validated during the General ledger consistency check.