How To Setup Database Log in AX 2012 using manually/using X++ Code for single Table/using X++ Code for all Table.
using Manually:
step1 : select System Administration -> setup -> Database -> Database log Setup
:
Step2 : when you click you will see this -> click on new
Step3: you will popup with wizard database logging -> Click on Next
Step4: select you table from here -> then click on Next
Step5: select tick in insert ,update, delete, according to you requirement. it is basically when someone insert , delete or update any record it will show in log. -> after that click on next
Step6: it will show how many tables you have selected and what command you have selected
once it done then check your select table in same place setup -> database-> database log setup
here you can find all changes which you have done.
now go to -> inquery-> database log (here you can check all the logs.
using X++ code for one table
Static Void aks_DBlogging(Args _args)
{
TableId tableId = tableNum(InventItemSalesSetup);
DatabaseLog log;
SysDictTable dictT = new SysDictTable(tableId);
SysDictField dictF;
Set fields;
SetEnumerator se;
log.logType = DatabaseLogType::Update;
log.logTable = tableId;
fields = dictT.fields(false,false,true);
se = fields.getEnumerator();
while (se.moveNext())
{
dictF = se.current();
log.logField = dictF.id();
log.insert();
info(strFmt("Adding field %1", dictF.name()));
}
SysFlushDatabaselogSetup::main();
}
using X++ code for All Table
static void aks_DBlogging(Args _args)
{
tableId tableId;
int tablecounter;
DatabaseLog log;
SysDictTable dictT;
SysDictField dictF;
Set fields;
SetEnumerator se;
Dictionary dict = new Dictionary();
for (tablecounter=1; tablecounter<=dict.tableCnt(); tablecounter++)
{
tableId = dict.tableCnt2Id(tablecounter);
// TableId tableId = tableNum(InventItemSalesSetup);
dictT = new SysDictTable(tableId);
log.logType = DatabaseLogType::Update;
log.logTable = tableId;
fields = dictT.fields(false,false,true);
se = fields.getEnumerator();
while (se.moveNext())
{
dictF = se.current();
log.logField = dictF.id();
log.insert();
info(strFmt("Adding field %1", dictF.name()));
}
}
SysFlushDatabaselogSetup::main();
}
No comments:
Post a Comment