Search code examples
axaptadynamics-ax-2012

Dynamics AX 2012 - Adding Tables to Database Logging Selection List


Is it possible to add tables to the Database Logging selection listing in AX 2012? If yes, is it possible to select which category each table appears in?

System Administration > Database > Database log setup > New

When I select Show all tables, some tables still do not appear. The tables do not appear in the Not specified category either.

We need to log additional AX built parameter tables as well developer built tables. The developer tables were built in the Development Workspace so we have access to all the Table properties.

DatabaseLogggingList


Solution

  • You can add new button to the form with custom code

    AddByTableName

    void clicked()
    {
        TableId promptTableId;
    
        Dialog d;
        DialogField df;
    
        void createLine(DatabaseLogType logType)
        {
            DatabaseLog.logTable = promptTableId;
            DatabaseLog.LogType = logType;
    
            DatabaseLog.insert();
        }
    
        d = new Dialog("Enter table name");
        df = d.addField(extendedTypeStr(TableName));
        d.parmIsModal(true);
    
        if (d.run())
        {
            promptTableId = tableName2id(df.value());
            if (!promptTableId)
            {
                 throw error(strFmt("Table %1 does not exists", df.value()));
            }
    
            ttsBegin;
            createLine(DatabaseLogType::Insert);
            createLine(DatabaseLogType::Update);
            createLine(DatabaseLogType::Delete);
            ttsCommit;
    
            SysFlushDatabaseLogSetup::main();
    
            info(strFmt("For table %1 (%2) records are created: %3, %4, %5."
                , tableId2name(promptTableId)
                , tableId2pname(promptTableId)
                , DatabaseLogType::Insert
                , DatabaseLogType::Update
                , DatabaseLogType::Delete
            ));
        }
    
        super();
    }