Thursday, May 21, 2009

Inline PDF viewer for Portal

Get PrintJobSettings From User

To get printjobsettings from user by clicking a button on AX, you can put the below code to clicked method of button
void clicked()
{
PrintJobSettings printJobSettings;
;
super();
printJobSettings = new PrintJobSettings(printset);

printJobSettings.printerSettings(formstr(SysPrintForm));

printset = printJobSettings.packPrintJobSettings();
}

Encode Barcode String For Any BarcodeType

Encode barcode just in a few lines of code:

Barcode barcode;
;
barcode = Barcode::construct(BarcodeType::Code39);
barcode.string(true, "Barcode_String");
barcode.encode();
itemBarcode = barcode.barcodeStr();

Un/Reservation By Code

server static void inventReservation(InventTransId _inventTransId,
InventSerialId _inventSerialId,
Qty _qty ,
boolean _unreserve=false)
{
InventUpd_Reservation inventUpd_Reservation;
inventMovement inventMovement;
InventSerial invserial;
inventdim inventDim,iDimNew;
SalesLine salesLine;
;
try
{
ttsbegin;
salesLine = SalesLine::findInventTransId(_inventTransId);
if (!salesline)
throw error('Sales Order Line could not be found !');
invSerial = InventSerial::find(_inventSerialId,salesLine.ItemId);
if (!invSerial)
throw error('Inventory Serial Number could not be found !');
inventDim = salesLine.inventDim();
inventdim.inventSerialId = _inventSerialId;
iDimNew = inventDim::findOrCreate(inventDim);
inventMovement = InventTrans::findTransId(salesLine.InventTransId).inventMovement(true);
inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventMovement,iDimNew,_unreserve ? _qty : -_qty);
inventUpd_Reservation.updateNow();
ttscommit;
}
catch (Exception::Deadlock)
{
retry;
}
}

AX 2009 – Adding Display method to Custom Lookup

AX 2009 brings capability to add display methods as well as adding table fields to custom lookups.

SysTableLookup.addLookupMethod(identifierstr(DisplayMethod));


So you can create a display method that gets only date of datetime field and display it in Lookup

Display bitmap on report

display Bitmap bitmap()
{
ResourceNode resNode=SysResource::getResourceNode('ResourceName');
container nodeData;
Image img;
;
if (resNode != null)
{
resNode.AOTload();
nodeData = SysResource::getResourceNodeData(resNode);
img = new Image(nodeData);
}
return img.getData();
}

Get the label description for any language

Label filed contains the description for each defined language. And it will automatically displayed in user's language on the forms (for reports it can be changed by code). But if you want to get that label's decription other than user's language. You will need to use below command that returns description that in given parameter languageId.
syslabel::labelId2String(literalstr('@LabelId'),'LanguageId')

How to add a range for the Array EDT to a query?

For the most cases dimensions have to be used in ranges. To do that you can use below code to add a range to a array element of that Dimension

qbrDimension = this.query().dataSourceNo(1).addRange(fieldid2ext(fieldNum(myTableName, Dimension), 1));

How many time user logged on to AX at the time (for 3 tier structure)

You can find the user logging count by using SysUsersOnline class as below.

container con1,con2;
;
con1 = conpeek(SysUsersOnline::getAllOnlineUserInfo(), 1);

for(counter1 = 1; counter1 <= conlen(con1); counter1++)
{
con2 = conpeek(con1, counter1);

if (conpeek(con2, 2) == curuserid())
{
countUser++;
}
}


Cookies usage on AX Portal

Cookies are important on web applications. You may want to keep some informations on client side, so you have to use cookies for Portal application. To set and get cookies from client side, below code will help you.

//Set Cookie with expiraton date&time
webSession().response().cookies().itemWriteCookie("InformationId=Value; expires=Fri, 31-Dec-2013 00:00:00 GMT");

//Get cookie
iis = new IISRequest();
webSession().writeTxt(iis.cookies().itemTxt(("InformationId")));

Sending XML file to webservice

Nowadays, using webservice for connecting different based systems is very popular. If you have to send xml data file to a webservice you firstly have to create a Microsoft.XMLHttp COM object variable to put xml string and to specify webservice address.

static void sendXML(Args _args)
{
url webServiceUrl;
COM myXmlHttp;
str s = '\r\n';
;
s += '\r\n';
s += 'V1.0\r\n';
s += '\r\n';
s += '1\r\n';
s += '';
myXmlHttp = new COM('Microsoft.XMLHTTP');
webServiceUrl = "http://webservice/webservice.aspx";
myXmlHttp.open("GET",webServiceUrl,false);
myXmlHttp.send(s);
}

What are the objects Dict* and How can we use them?

In some cases we need to write some codes in Dict objects. If we look under AOT\System Documentation\Classes node, here are the objects we will discuss in this post.

Dict objects are generally used for creating a object of related type (for DictClass e.g. CustBalanceList class), getting information about that object (for DictClass e.g. is class defined Abstract, Final or is Runnable {has main method} ) etc.

DictClass

Object can be constructed by “new” word (Params: ClassId). Mostly and effectively used for creating a child class (if we know classId of it).

Example usage in AX Classes\VenOutPaymRecord\newVendOutPaymRecord
Example code

//A child class will be created by using dictclass

DictClass dictClass;
VendOutPaymRecord vendOutPaymRecord; // parent class is defined
;

if (! _vendPaymModeSpec.classId)
{ // Payment mode specification has the child class id
return null;
}

if (! SysDictClass::isSuperclass(_vendPaymModeSpec.classId, classNum(VendOutPaymRecord)))
{ //Be sure if child class is really child
return null;
}

dictClass = new DictClass(_vendPaymModeSpec.classId); //Initialize dictclass object by child class id
vendOutPaymRecord = dictClass.makeObject(); // Create real child class by calling makeObject method

if (! vendOutPaymRecord) // Check if class was made or not
{
return null;
}

DictConfigurationKey

Object can be constructed by “new” word (Params: ConfigurationKeyId). Mostly used for checking if configuration key is enabled or not

Example usage in AX Classes\PurchLineType\interCompanyMirror
Example code

//Check if SalesDeliveryDateControl configuration key is enabled

if (new DictConfigurationKey(configurationkeynum(SalesDeliveryDateControl)).enabled())

DictEnum

Object can be constructed by “new” word (Params: EnumId). Mostly used for returning all of the elements of any enum object and accessing name of them.

Example usage in AX Classes\InventItemType\valueCanBeProduced
Example code

//Check if SalesDeliveryDateControl configuration key is enabled

DictEnum dictEnum;
Counter i;
InventItemType inventItemType;
str itemTypeTxt;
;

dictEnum = new DictEnum(enumnum(ItemType)); // ItemType is a variable that value determined at outer of method earlier
for (i=0;i// This block will loop until the end element of enum
{
inventItemType = InventItemType::construct(i);
if (inventItemType.canBeProduced())
{
itemTypeTxt += itemTypeTxt ? ',' : '';
itemTypeTxt += queryValue(dictEnum.value2Name(i)); // Here, enum name is extracting from enum value
}
}

return itemTypeTxt ? itemTypeTxt : SysQuery::valueEmptyString();

DictField

Object can be constructed by “new” word (Params: TableId, FieldId). Mostly used for finding basetype or label etc of any table field.

Example usage in AX Classes\SysApplCheck\checkFieldDefaultReport
Example code

// This example will show some functionalities of DictField class

#MacroLib.DictField // will be used for flag testing
DictField dictField = new DictField(Tablenum(ContactPerson), FieldNum(ContactPerson,Name));
;
dictField.enumId(); // If that field was the type of enum, that method would return enumid (now is zero)
dictField.arraySize(); // In default array size is 1 (for EDT Dimension , array size bigger than 1)
if (bitTest(dictField.flags(),#DBF_CHANGE))
info('Allow edit property of the field is true');
dictField.relationObject(); // can be used for determining main table of EDT of the field. That expression will return dictRelation object
dictField.label(); // label of the field
dictField.stringLen(); // if field is the typeof string, that will return length of string (nonzero) value

DictFieldGroup

Object can be constructed by “new” word (Params: TableId, FieldGroupName). Mostly used for determining the fields in the fieldgroup of a table.

Example usage in AX

Classes\SysReportWizard\fieldFillContainer
Example code

// This example will show some functionalities of DictFieldGroup class

dictFieldGroup = new DictFieldGroup(TableNum(CustTable), ‘Address’); // Will Process Address fieldgroup of CustTable
fieldGroupName = dictFieldGroup.name(); // will return the string ‘Address’
fieldGroupElement = connull();
lastFieldElement = 0;

for (j=1; j <= dictFieldGroup.numberOfFields(); j++) //Determine the # of fileds in group
{
methodName = dictFieldGroup.methodName(dictFieldGroup.field(j)); //If the element in group is display or edit method ‘methodname’ variable will be the name of the method
if (methodName) //If the element is method then do something…
{

}
else // otherwise this is a table field
{
sysDictField = new SysDictField(dictTable.id(), dictFieldGroup.field(j)); // get dictfield and do something…
for(k = 1; k <= sysDictField.arraySize(); k++)
{

}
}
}

DictIndex

Object can be constructed by “new” word (Params: TableId, IndexId). Mostly used for finding the fields of the index or checking if it allow duplicates or not.

Example usage in AX

Classes\SysDictField\isUnique

Example code

// This example will show some functionalities of DictIndex class

DictTable dictTable;
DictIndex dictIndex;
int indexId;
int i;
fieldId fieldId;

if (this.mandatory())
{
dictTable = new DictTable(this.tableid());
fieldId = fieldExt2Id(this.id());
if (dictTable.primaryKeyField() == fieldId)
return true;

for (indexId = dictTable.indexNext(0); indexId; indexId = dictTable.indexNext(indexId)) // loop index of table
{
dictIndex = dictTable.indexObject(indexId); // get dictIndex from dictTable
if (!dictIndex.allowDuplicates()) // check if index property allowDuplicates is true or false
{
for (i=1; i<=dictIndex.numberOfFields(); i++) // loop thru fields of index
{
if (dictIndex.field(i) == fieldId) // get fieldId of the current field
return true;
}
}
}
}
return false;

Dictionary

Object can be constructed by “new” word (no Params required). Dictionary class is the general class for getting some informations about every AOT object.

Example usage in AX

Classes\ProjTableType\returnClass

Example code

// This example will show some functionalities of Dictionary class (Only for class related methods).

Dictionary dict = new Dictionary();
int i;
;
for (i = 1; i<=dict.classCnt(); i++) // Loop thru the classes in AOT
{
print dict.classCnt2Id(i); // classid of class
print dict.classFlush(); // Restore class object
print dict.className(dict.classCnt2Id(i)); // name of class
print dict.className2Id(dict.className(dict.classCnt2Id(i))); // will print same value as dict.classCnt2Id(i)
print dict.classNext(dict.classCnt2Id(i)); // classid of the next class after the current class
print dict.classObject(dict.classCnt2Id(i)); // constructs dictClass of the current class object
}
pause;

DictLicenseCode

Object can be constructed by “new” word (Params: LicenseCodeId). Mostly used for finding licensecode group

Example usage in AX

Classes\SysLicenseCodeReadFile\createCodes

Example code

// This example will show some functionalities of DictLicenseCode class

sysDictLicenseCode = new DictLicenseCode(dictionary.licenseCodeCnt2Id(i)); //construct licensecode object
if (sysDictLicenseCode) // if constructed
{
switch (sysDictLicenseCode.group()) // get group of license code ie. System,Partner,Web etc
{
case LicenseCodeGroup::Language:
print sysDictLicenseCode.id(); // get licensecode id and print

break;
}
}

DictMethod

Object can be constructed by “new” word (Params: UtilElementType, Id, Name). Mostly used for accessing method properties such as return type, parameters etc.

Example usage in AX

Classes\SysApplCheck\checkTableFieldPnameMustBeUnique

Example code

// This example will show some functionalities of DictMethod class

DictMethod dictMethod;
;
// If you want to create dictMethod of the type
//
// ClassInstanceMethod
// ClassStaticMethod
// then 2nd parameter will be ClassId
//
// TableInstanceMethod
// TableStaticMethod
// then 2nd parameter will be TableId
dictMethod = new DictMethod(UtilElementType::ClassInstanceMethod,
classNum(CustInPaym),
identifierstr(loadVoucherNum));
print dictMethod.returnType(); // prints return type (void)
print dictMethod.isAbstract(); // prints if the method is abstract (false)
print dictMethod.parameterCnt(); // prints parameter count of method (0)
print dictMethod.accessSpecifier(); // prints access specifier (public)
print dictMethod.returnId(); // prints EDT id of return type (in this case 0 = void)
print dictMethod.noParms(); // prints 1 which means there is no parameter required for that method
print dictMethod.parentId(); // in this case prints classid (72) (because of method is class instance method)
pause;

DictRelation

Object can be constructed by “new” word (Params: TableId). Mostly used for determining relation of two tables.

Example usage in AX

Classes\SysSeachResultForm\getMainRecord

Example code

// This example will show some functionalities of DictRelation class

private static Common getMainRecord(int iPMainTableId, int iPLinesTableId, Common CPLinesTableRecord)
{
DictRelation CDictRelation;
int i;
DictField CMainDictField;
DictField CLineDictField;
Query CQuery = new Query();
QueryRun CQrun;
Common CMainTableRecord;

;

CDictRelation = new DictRelation( iPLinesTableId ); // construct dictrelation according to line table
CDictRelation.loadTableRelation( iPMainTableId ); // give tableid to be found relation

// get list of fields that one table has to another
// and build query to main table
CQuery.addDataSource( iPMainTableId );
if (CDictRelation.lines())
{
for (i = 1; i <= CDictRelation.lines(); i++)
{
CMainDictField = new DictField(iPMainTableId, CDictRelation.lineExternTableValue(i)); // Here is the point, that job of dictrelation begins. CDictRelation.lineExternTableValue(i) returns maintable relation field
CLineDictField = new DictField(iPLinesTableId, CDictRelation.lineTableValue(i)); // And CDictRelation.lineTableValue(i) returns line table relation field
CQuery.dataSourceTable( iPMainTableId ).addRange( CMainDictField.id() ).value( queryValue( CPLinesTableRecord.( CLineDictField.id() ) ) );
}
}
CQrun = new QueryRun(CQuery);
CQrun.next();
CMainTableRecord = CQrun.get(iPMainTableId);

return CMainTableRecord;
}

DictSecurityKey

Object can be constructed by “new” word (Params: SecurityKeyId). Mostly used for checking if the user has securitykey access.

Example usage in AX

Classes\Global\hasSecurityKeyAccess

Example code

// Below method will explains DictSecurityKey class briefly

static boolean hasSecuritykeyAccess(securityKeyId securityKeyId, AccessType neededAccessLevel)
{
DictSecurityKey dsk=new DictSecurityKey(securityKeyId); // Construct class
;

if (dsk == null) // if not constructed then there is no such a securityKey
return false;
else
return dsk.rights() >= neededAccessLevel; // rights method will return current user’s AccessType (eg. NoAccess or View etc) to SecurityKey
}

DictTable

Object can be constructed by “new” word (Params: TableId). Mostly used for getting information and calling methods of table.

Example usage in AX

Classes\SysApplCheck\checkForm

Example code

// Below method will explains DictTable class briefly

DictTable dictTable;
CustTable custTable;
CustAccount accountNum = 'CustomerNo1';
;
select custTable
where custTable.AccountNum == accountNum; // we will use that record below
// we can construct table, map, view
dictTable = new DictTable(tablenum(CustTable)); // Construct dictTable class (here we will use CustTable as an example)
print dictTable.callObject(identifierstr(countryName),custTable); // callObject will execute 'countryName' instance method using the selected record above and returns value/object (according to the method return type)
print dictTable.callStatic(identifierstr(blocked),accountNum); // this will execute 'blocked' static method and returns value/object (according to the method return type)
print dictTable.fieldGroupCnt(); // prints count of fieldgroup in that table (CustTable)
CustTable = dictTable.makeRecord(); // makes a new record
dictTable.isMap(); //is object type of Map?
dictTable.isView(); //is object type of View?
dictTable.isTmp(); // (if it is table) is it temporary table?
print dictTable.titleField1(); // prints titlefield1 (fieldnum) property of table (is it is table)
pause;

DictType

Object can be constructed by “new” word (Params: extendedTypeId). Mostly used for getting information about any type.

Example usage in AX

Classes\AifMessage\validateString

Example code

// Below method will explains DictType class briefly

DictType dictType = new DictType(extendedTypeNum(CustAccount));
;
print global::extendedTypeId2name(dictType.extend()); // prints CustVendAC (ie. extend type of dictType)
print dictType.label(); // prints "Customer account" which is label of dictType
dictType.relationObject(); // returns DictRelation which contains relation to table which is specified in EDT
dictType.stringLen(); // if it is the type of string, then prints string length of dictType
dictType.configurationKeyId(); // returns "configurationKeyId" of dictType
pause;

Round function

Round function gets two parameters, first one is variable type of real which is the number to be rounded and the other one is decimal which will be used as sensitivity constant. What does mean sensitivity? Let’s dive into examples.

    round(23.79, 0.1) = 23.80 . The explanation of the result is:
      Closest multiple to the number of 0.1 is on the left : 23.70 and on the right : 23.80. But the closest one is 23.80 ie. the result.
    round(23.79, 0.5) = 24.00 . The explanation of the result is:
      Closest multiple to the number of 0.5 is on the left : 23.50 and on the right : 24.00. But the closest one is 24.00 ie. the result.
    round(23.79, 10) = 20.00 . The explanation of the result is:
      Closest multiple to the number of 10 is on the left : 20.00 and on the right : 30.00. But the closest one is 20.00 ie. the result.
    round(23.5, 0.1) = 24.00 . The explanation of the result is:
      Closest multiple to the number of 0.1 is on the left : 23.00 and on the right : 24.00. Which have equal distance to the number. In this case bigger one will be taken into account which is 24.00 ie. the result.
    round(23.5, 50) = 0.00 . The explanation of the result is:
      Closest multiple to the number of 50 is on the left : 0.00 and on the right : 50.00. But the closest one is 0.00 ie. the result.

<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>

Above shape shows behavior of round function. Thus, There are two boundaries, lower and upper, rounded number will be lower boundary if number is closer to lower boundary and vice versa. Special case the middle boundary ( (lower+upper) / 2 ), which the result will be upper one

Stack Class

Stack Class

Stack Class

Stack Class

Web Popup Weblet

Web popup weblet

KeySum Class

KeySum class is useful for summing data linked to keys. For example you may want to sum Invoice Amount while looping in CustInvoiceJour with grouping in Customer Group. So I recommend to use that handy class. No need to explain in theoretic let’s go practical.

KeySum keySum; // Define keySum class
;
// Initializing class:
// First Param: NumOfKeys : Length of key.
// If you specify that value 2, you have to give it a container which length of it is 2.
// Second Param: NumOfData : Length of data.
// If you specify that value 2, you have to give it a container which length of it is 2.
// Third Param: Sorting
// -1 : Descending order according to key
// 0 : It does not sort
// 1 : Ascending order according to key
keySum = new KeySum(1, 1, 0); // Initialize
keySum.updateNow(1, 15); // keySum = [1 -> 15]
keySum.updateNow(2, 47); // keySum = [1 -> 15, 2 -> 47]
keySum.updateNow(1, 100); // keySum = [1 -> 115, 2 -> 47]
keySum.updateNow(3, 15); // keySum = [1 -> 115, 2 -> 47, 3 -> 15]
keySum.updateNow(7, 47); // keySum = [1 -> 115, 2 -> 47, 3 -> 15, 7 -> 47]
keySum.updateNow(4, 100); // keySum = [1 -> 115, 2 -> 47, 3 -> 15, 7 -> 47, 4 -> 100]
print keySum.key2Data(1); // prints 115 = which is sum of 15 + 100 i.e. the data we loaded earlier for the key 1
print keySum.total(); // prints 324 which is grand total of all the data
print keySum.numOfTrans(); // prints 5 = which is the count of the keys (1,2,3,4,7)
keySum.keyDelete(2); // deletes key 2 -> 47. So total is decreased to 324-47 = 277
keySum.addKeySum(keySum); // addKeySum method can be merged with another keySum object. In this case we did with itself
print keySum.total(); // total is doubled so 277*2 = 554
pause;

Tuesday, May 19, 2009

Working with Dynamics AX Table Meta Data

Background
Recently I had to create a custom database log for a client. Dynamics AX does come with a database log feature (with the proper license key). However, my client wanted something different to allow easier reporting and tracking of changes. The log must be searchable, filterable, and sortable based on any field. For instance, if the CustTable updates were being logged, the user must be able to search, filter, and/or sort by CustGroup, AccountNum, or any other field that was logged. The standard log does not have this capability.

It was decided that in order to achieve these goals, each table to be logged (source) should have its own log table. The log table would mirror the table structure of the source table, with some additional log specific fields, such as log type, date and time of log, changed by, etc. The custom log needed to be able to record the same table events as the standard log (inserts, updates, deletes, and rename keys).

Problem
I had to have a way to perform a field-to-field data transfer from the source table to the log table (ie. source.AccountNum --> log.AccountNum). My initial thought was to copy the data using the intrinsic "data" method on table buffer object. This method allows a table buffer (record) to be passed to the "data" method of another (empty) table buffer to be copied field for field, with the exception of system fields like RecId, RecVersion, etc. It turns out that a field-to-field data copy only works if the two table buffers are of the same table. Unfortunately, even if the field names were the same, the "data" method does not copy the data if the table buffers objects were for different tables.

I needed to write my own data copy function. My function had to be generic, because I didn't want to hard-coded the field name and the mappings between the source and log tables. Additionally, I didn't want to have to update my code each time a new field was added or removed from the source table. In order to make the log function in a generic way, I needed to the meta data within Dynamics AX.

Solution
Below is the code for the static method I created to transfer the data from the source table to the log table. I've placed comments in red to explain the interesting parts of the code.

Basically the method loops through the fields of the source table, and assigns it to the corresponding field in the log table. By using the SysDictTable class, I'm able to retrieve the field list for the source table. This allows me to "see" all the fields, including newly added fields. I also do not have to deal with deleted fields, because they won't appear in the field list.

The challenging part of this method was dealing with array fields. These are fields that are based on an extended data type that is an array. A prime example of this type of field is the "Dimension" field found in many master and transactions tables. Each array element translates to a single field in the table in the database. In Dynamics AX, an array field appears as a single field would. It has a field ID just like any other field, with one exception. An array field has what's called an "extended field ID". This is the combination of the field's ID and the element's position or index in the array. Therefore, to properly retrieve the data for an array field, you must properly address the field's array element to get the correct field ID. This can be done via the "fieldId2Ext" function.

static void copyDataToLog(Common _fromTable, Common _toTable)
{
SysDictTable fromDictTable;
SysDictField fromDictField;
SysDictTable toDictTable;
SysDictField toDictField;
int fields;
int fieldIndex;
int arraySize;
int arrayIndex;
int fromFieldId;
int toFieldId;

;

// Instantiate the SysDictTable object. The SysDictTable class
// extends the DictTable class. By using the SysDictTable class,
// instead of the DictTable class, you get the ability override methods,
// and get the field list, among other things.
//
// I use the SysDictField class in the same way as I use the
// SysDictTable class to process and the retrieve meta data
// about the fields. It provides information about each field.

fromDictTable = new SysDictTable(_fromTable.TableId);
toDictTable = new SysDictTable(_toTable.TableId);

// Loop through the field list for the source table.
// Note that the loop excludes the system fields, such as
// RecId, RecVersion, CreatedDate, CreatedBy, etc. Each
// table will have its own set of system fields, which will be
// populated by Dynamics AX when the record is inserted.

fields = fromDictTable.fieldCnt();

for (fieldIndex = 1; fieldIndex <= fields; fieldIndex++)
{
fromDictField = new SysDictField(fromDictTable.id(),fromDictTable.fieldCnt2Id(fieldIndex));

if (!fromDictField.isSystem())
{
// Some tables contain fields that inherit from array extended data
// types. An example of an array field is the "Dimension" field,
// found in tables throughout the database.
// Each element in the array field corresponds to a real field
// in the database. The concept of field ID still exists for array
// fields, but with a little twist. The field ID for each
// array element is called an "extended field ID". This extended
// field ID is the combination of the field ID and the array index
// for the element.
// The function "fieldId2Ext" provides a way to get an array field's
// field ID.

if (fromDictField.arraySize() > 1)
{
// Field is an array (ie. Dimension).
arraySize = fromDictField.arraySize();

// Loop through each array field's element to copy its value
// to the corresponding log array field's element.

for (arrayIndex = 1; arrayIndex <= arraySize;arrayIndex++)
{
fromFieldId = fieldId2Ext(fromDictField.id(),arrayIndex);
toFieldId = fieldId2Ext(fieldName2Id(_toTable.TableId, fromDictField.name()), arrayIndex);

// Note that field values may be assigned and retrieved using
// the field ID instead of the field name.

_toTable.(toFieldId) = _fromTable.(fromFieldId);
}
}
else
{
// Use the "fieldName2Id" function to convert the field name
// from the source table to the corresponding field ID for the
// log table. This is possible because the field names in the log
// table are the same as the source table.

toFieldId = fieldName2Id(_toTable.TableId,fromDictField.name());

_toTable.(toFieldId) = _fromTable.(fromDictField.id());
}
}
}
}




Conclusion
Using this static method, I'm able to copy the source table fields to the log table fields. This method illustrates one possible usage of system meta data as provided by the "Dict*" classes to perform generic work. These classes provided the necessary information about the table and fields to perform the task without the need to hard-code table or field names. There are several other "Dict" classes that provide information about other application objects.

Some ref to utilelement table and creation of shared project

As far my experience utilelements table get updated when the service is started.
It may also get updated when the customisation is imported into the application.

The code shown below how to delete a shared project

treenode c1,c2;
;

c1 = systemnode::getsharedproject();
c2 = c1.aotfindchild("project1");

c2.aotdelete();
c2.aotrefresh();
c2.aotsave();

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...