Condividi tramite


Updating the Audit Trail (a.k.a. Transaction Log)

Dynamics AX offers an audit trail feature where all ledger postings can be tracked.
The audit trail can be seen from General ledger\Inquiries\Audit trail.

Of  course when you write code that posts transactions to the ledger you must always use a LedgerVoucher object. I guess everyone could figure that one out. But you should also write code to update the audit trail and that is often forgotten.

The audit trail is held by the table TransactionLog and records are inserted in the audit trail by calling the static method TransactionLog::Create(Type, Text). Type is an enumeration of the TransactionLogType enum and Text should disclose details about the context of the business transaction, i.e. "Customer free text invoice".

If the business transaction implements other business transactions you could end up adding more that one entry to the transaction log. One for each involved part. To prevent this only the log entry from the initianting business transaction is recorded. Thus the log works on a transactional level according to the tts levels, and records are only inserted when the Create method is called in tts level 1 as shown below.

If posting of the LedgerVoucher object takes places place outside a transaction (tts level  0)  it is possible to call the LedgerVoucher object with a transaction log type and text and the LedgerVoucher object will insert a record to the audit trail without you calling it explicit.

If a business transaction job does not update the audit trail, a transaction will still be inserted to the audit trail by a TransactionlogUpdateTTSControlobject. The entry will of course not be able to disclose any information about the type or context of the business transaction. It simply records that a busniess transaction took place.

The TransactionlogUpdateTTSControl object works as a kind of flag initated whenever someone posts transactions with a LedgerVoucher object and it is checked when ttsCommit is executed.

Your job is to keep the TransactionlogUpdateTTSControl object unemployed by updating the audit trail with valid information yourself. When TransactionlogUpdateTTSControl actually gets to write the log entry you should consider it beeing a bug in your code.

This posting is provided "AS IS" with no warranties, and confers no rights.

Comments