How to read/parse Data field in SysDataBaseLog Table in AX 2012

Hi Folks,

This is important thing to discuss as Data field extends Blobdata which is of type Container. This Data field in SysDataBaseLog table is presented as  2x array (container in container) with structure like

[

[fieldNum1, newFieldValue1, oldFieldValue1,]

,[fieldNum2, newFieldValue2, oldFieldValue2]

,[fieldNumN, newFieldValueN, oldFieldValueN]

container within container

Lets take an example to understand.

SysDataBaseLog log;
container conData, conField;
int i, tableId = tableNum(YourTable);
str oldFieldValue, newFieldValue;

select firstonly log where log.table == tableId;

if(log)
{
conData = log.Data;

for (i=1; i<=conLen(conData); i++)
{

conField = conPeek(conData, i);
if(fieldName2id(tableId, conPeek(conField, 1)) == fieldNum(YourTable, YourField))
{
newFieldValue = conPeek(conField, 2);
oldFieldValue = conPeek(conField, 3);
}
}
}
SysDataBaseLog table has method SysDataBaseLog.fieldChanged(fieldId) returns whether field has changed or not.


SysDataBaseLog table has method SysDataBaseLog.getDataAsList().
It takes values in the Data field and returns them as a list.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: