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
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
网友评论