美文网首页
Ax add database log by table nam

Ax add database log by table nam

作者: axxxxxxxx | 来源:发表于2018-04-24 15:09 被阅读0次

Add a new button to add database log by table name
Reference link is :
https://stackoverflow.com/questions/36798563/dynamics-ax-2012-adding-tables-to-database-logging-selection-list

image.png
image.png
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();
}

Log is stored in database "sysDatabaselog"


image.png

we can query the result in AX


image.png

相关文章

网友评论

      本文标题:Ax add database log by table nam

      本文链接:https://www.haomeiwen.com/subject/emdjlftx.html