Dynamics AX 2012 - 将表添加到数据库日志记录选择列表

Dynamics AX 2012 - Adding Tables to Database Logging Selection List

是否可以将 table 添加到 AX 2012 中的 Database Logging selection 列表中?如果是,是否可以 select 每个 table 出现在哪个类别?

系统管理 > 数据库 > 数据库日志设置 > 新建

当我selectShow all tables的时候,有些table还是没有出现。 table 也没有出现在 Not specified 类别中。

我们需要记录额外的 AX 内置参数 tables 以及开发人员内置的 tables。开发人员 table 是在开发工作区中构建的,因此我们可以访问所有 Table 属性。

您可以使用自定义代码向表单添加新按钮

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

方法 buildTableTree 形式 SysDatabaseLogWizard 似乎是开始寻找问题答案的好地方:

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?

是的,您必须修改 table 的配置键才能更改类别。请注意,根配置键用作类别,因此请先检查 table 的配置键是否有父键(例如 table CommissionCustomerGroup 有配置键 Commission它具有配置键 LogisticsBasic 作为父键,因此 table 出现在类别 Trade 中)。

请注意,更改配置键可能会产生其他后果,我不建议仅仅为了更改数据库日志记录选择的类别而这样做。

根据您观察到的一些 table 未列出的情况,必须满足几个条件才能列出 table:

  • 必须启用(dictTable.enabled(),我猜这意味着配置密钥已启用)
  • 有 table 主组或选项 "Show all tables" 已启用,或者 table 已设置用于日志记录
  • table 既不是 table SysDataBaseLog 也不是 SysUserLog
  • table不是临时的table
  • table 不是地图
  • 可以为 table id
  • 创建一个 DictTable 实例

如果您缺少的 table 满足这些条件,我建议调试 SysDatabaseLogWizard 形式的方法 buildTableTree 以找出为什么 table 没有添加到树中控制。