web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Enable database logging on groups and parameters

Kurt Hatlevik Profile Picture Kurt Hatlevik 2,067

First I would say that I do NOT recommend to enable any database logging, unless it is business important for you, and you need to have a track of parameter changes.

But in some cases customers demand to have database logging.  I agreed and explained that it will have performance consequences, but we could do it on parameters and groups.

But I’m a type of guy that likes to create scripts to enable things.  So I wanted to share with you a small script that enables database logging on all groups and parameters.

(This script is for AX2009)

static void KHA_AddDatabaseLogging(Args _args)
{
    #AOT Name name;

    TreeNode treeNode;
    SysDictTable sysDictTable;
    DatabaseLog  DatabaseLog;
    ;
    treeNode = TreeNode::findNode(#TablesPath);
    treeNode = treeNode.AOTfirstChild();
    while (treeNode)
    {
        name = treeNode.AOTname();
        sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());

        if ((sysDictTable.tableGroup() == tableGroup::Parameter ||
             sysDictTable.tableGroup() == tableGroup::Group) &&
             !sysDictTable.isMap() &&
             !sysDictTable.isTmp() &&
             !sysDictTable.isView() &&
             sysDictTable.enabled())
        {
            select firstonly DatabaseLog where DatabaseLog.logTable == sysDictTable.id();
            
            if (!DatabaseLog)
            {
                DatabaseLog.domainId = "Admin";
                DatabaseLog.logType  = DatabaseLogType::Update;
                DatabaseLog.logTable = sysDictTable.id();
                DatabaseLog.logField = 0;
                DatabaseLog.insert();
            }
            info(strfmt("Databaselogging enabled on %1",sysDictTable.name()));
        }
        treeNode = treeNode.AOTnextSibling();
    }
}



This was originally posted here.

Comments

*This post is locked for comments