Tuesday, July 27, 2010

Create Delete Actions through code in AX

Hi Folks,

It has been a long time, since I have posted any blog because of my busy project schedule.............
In this post, I am going to discuss on how to create delete actions through code in AX.

Let us create a delete action in InventTable for a testTable.

SysDictTable table;
Treenode treeNode, datreeNode;
table = new sysdicttable(tablename2id("InventTable"));
treeNode = table.treeNode();
treeNode = treeNode.AOTfindChild("DeleteActions");
DAtreeNode = treeNode.AOTadd('UNKNOWN');
DAtreeNode.AOTsetProperty("Table", "TestTable");
DAtreeNode.AOTsetProperty("DeleteAction","Cascade");
DAtreeNode.AOTsave();
In the above code snippet, we get into the AOT node by node and go till the delete actions of the table and then create the delete actions for that table.

After executing this code, just open the AOT and click on save icon. Now, just close the AX client and re-open it again. Now, you can find the delete actions created through code.

No comments: