Extensions In D365

Table Extensions :

The following table lists each table method and its events.

Published Table method Preceding event Succeeding event
validateWrite ValidatingWrite ValidatedWrite
validateDelete ValidatingDelete ValidatedDelete
validateField ValidatingField ValidatedField
validateFieldValue ValidatingFieldValue ValidatedFieldValue
modifiedField ModifyingField ModifiedField
modifiedFieldValue ModifyingFieldValue ModifiedFieldValue
Insert Inserting Inserted
Update Updating Updated
Delete Deleting Deleted
Initvalue InitializingRecord InitializedRecord
FinalDeleteValidation Executed when a delete operation is performed on a table object, before the operation is committed to the underlying database table N/A
FinalInsertValidation Executed when an insert operation is performed on a table object, before the operation is committed to the underlying database table N/A
FinalReadValidation Executed when a read operation is performed on a table object. N/A
FinalUpdateValidation  Executed when an update operation is performed on a table object, before the operation is committed to the underlying database table. N/A

 

Change Table & Field Properties in Ax 2012 by X++

Change Tables Field Properties:

static void ChangeTableFieldProperties(Args _args)
{
TreeNode FldsRoot = treeNode::findNode(@"\Data Dictionary\Tables\ChangeLabel\Fields");
TreeNodeIterator FldsIterator;
TreeNode Flds;
str newLabel = "Cust Name";
str property;

FldsIterator = FldsRoot.AOTiterator();
Flds = FldsIterator.next();
while(Flds)
{
if(Flds.AOTgetProperty('Name') == 'CustomerName')
{
property = setProperty(Flds.AOTgetProperties(),"Label",newLabel);
info(property);
Flds.AOTsetProperties(property);
Flds.AOTsave();
Flds.AOTrefresh();
}
Flds = FldsIterator.next();
}
}

Change Tables Properties:

static void ChangeTableProperties(Args _args)
{
xInfo xInfo = new xInfo();
treeNode node = xInfo.rootNode().AOTfindChild("Data Dictionary");
treeNode childNode;
treenodeIterator nodeIterator;
str properties;
str tables;
str newLable = "Change label";
;

node = node.AOTfindChild("Tables");
nodeIterator = node.AOTiterator();
childNode = nodeIterator.next();
while (childNode)
{
tables = childNode.treeNodeName();
if(tables == "ChangeLabel")
{
properties = setProperty(childNode.AOTgetProperties(), "Label", newLable);
info(properties);
childNode.AOTsetProperties(properties);
childNode.AOTsave();
childNode.AOTrefresh();
break;
}
childNode = nodeIterator.next();
}
}

Table method calling sequences

When you press CTR+N

inItValue()->

When you change data in a field

validateField()  -> validateFieldValue() ->  ModifiedField() ->  ModifiedFieldValue()

When you close the table after entering some data

validateWrite() – > Insert()  -> aosValidateInsert()

When you open the table which will contain some data

If table will contain 10 records this method is called 10 times

aosValidateRead()

When you Save the Record for the first time

validateWrite() ->Insert() – > aosValidateInsert()

When you modify the record and saving

validateWrite() -> update() – > aosValidateUpdate()

When you delete the record

validateDelete() -> delete() -> aosValidateDelete()

Reference:http://msdaxerp.wordpress.com/2013/02/27/345/