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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Trying to find what Log Entry types there are

(0) ShareShare
ReportReport
Posted on by

In AX 4.0 you can click on record info->Database Log->History and there is a field called "type of change". I am trying to capture that string so that I can update a table with only updates where there have been changes to certain fields. Is there a way to do this?

heres the code:

static void SysDatabaseLogExtract_InventTableModule(Args _args)
{
//NOTE: job takes about 15-20 minutes. Delete all records from "inventTableModuleLog" first

InventTableModule inventTableModule;
PMF_InventTableModuleLog inventTableModuleLog;

SysDataBaseLog log;
container tmp;
FieldId fieldId;

List datalist;
ListEnumerator enumerator;
boolean dataFound;
int cntInsert;
;

// only sales type where log records exist
while select inventTableModule
where inventTableModule.ModuleType == ModuleInventPurchSales::Sales
join log
where log.table == inventTableModule.TableId
&& log.LogRecId == inventTableModule.RecId
{
inventTableModuleLog.clear();
inventTableModuleLog.Price_New = -999;
inventTableModuleLog.Price_Old = -999;
inventTableModuleLog.PriceUnit_New = -999;
inventTableModuleLog.PriceUnit_Old = -999;
dataFound = false;
datalist = log.getDataAslist();
enumerator = datalist.getEnumerator();
while (enumerator.moveNext())
{
tmp = enumerator.current();
fieldId = conpeek(tmp, 1);

// NOTE: run job "getFieldId" to get extended fieldIds

if(fieldId==65540) // Price
{
if(conpeek(tmp,3) != "" && log.LogType.ToString() == "Update") //Doesn't work
{
inventTableModuleLog.Price_New = conpeek(tmp,2);
inventTableModuleLog.Price_Old = conpeek(tmp,3);
dataFound = true;
}
else
{
DataFound = false;
}

if(log.LogType == "Insert")
{
inventTableModuleLog.Price_New = conpeek(tmp,2);
inventTableModuleLog.Price_Old = conpeek(tmp,3);
dataFound = true;
}
}
if(fieldId==65541) // PriceUnit
{
if(conpeek(tmp,3) != "" && log.LogType == "Update")
{
inventTableModuleLog.PriceUnit_New = conpeek(tmp,2);
inventTableModuleLog.PriceUnit_Old = conpeek(tmp,3);
dataFound = true;
}
else
{
DataFound = false;
}

if(log.LogType=="Insert")
{
inventTableModuleLog.PriceUnit_New = conpeek(tmp,2);
inventTableModuleLog.PriceUnit_Old = conpeek(tmp,3);
dataFound = true;
}
}
if(fieldId==65560) // OverDeliveryPct
{
if(conpeek(tmp,3) != "" && log.LogType == "Update")
{
inventTableModuleLog.OverDeliveryPct_New = conpeek(tmp,2);
inventTableModuleLog.OverDeliveryPct_Old = conpeek(tmp,3);
dataFound = true;
}
else
{
dataFound=false;
}
if(log.LogType == "Insert")
{
inventTableModuleLog.OverDeliveryPct_New = conpeek(tmp,2);
inventTableModuleLog.OverDeliveryPct_Old = conpeek(tmp,3);
dataFound = true;
}
}
if(fieldId==65561) // UnderDeliveryPct
{
if(conpeek(tmp,3) != "" && log.LogType == "Update")
{
inventTableModuleLog.UnderDeliveryPct_New = conpeek(tmp,2);
inventTableModuleLog.UnderDeliveryPct_Old = conpeek(tmp,3);
dataFound = true;
}
else
{
dataFound=false;
}

if(log.LogType == "Insert")
{
inventTableModuleLog.UnderDeliveryPct_New = conpeek(tmp,2);
inventTableModuleLog.UnderDeliveryPct_Old = conpeek(tmp,3);
dataFound = true;
}
}
}
if(dataFound)
{
inventTableModuleLog.Description = log.Description;
inventTableModuleLog.LogType = log.LogType;
inventTableModuleLog.table = log.table;
inventTableModuleLog.LogRecId = log.LogRecId;
inventTableModuleLog.LogCreatedDate = log.createdDate;
inventTableModuleLog.LogCreatedTime = log.createdTime;
inventTableModuleLog.LogCreatedBy = log.createdBy;
inventTableModuleLog.ItemId = substr(log.Description,1,strfind(log.Description,',',1,99)-1);
inventTableModuleLog.insert();
cntInsert++;
}
}

info(strfmt("%1 records inserted",cntInsert));
}

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,849 Super User 2025 Season 2 on at

    Hi,

    You can setup the database log to log only changes to some fields. You have to select the fields from the table to log the update instead of the table node itself when setting up the database log.

    However if you are only concerned about the sales type records, it will log too much.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans