![]() |
#1 |
Участник
|
axblog4u: TreeNode AOT Save – Did you know?
Источник: http://axblog4u.wordpress.com/2010/1...-did-you-know/
============== Today I had a small requirement from one of my colleague stating he would like to update a particular table field property using X++ code for upgrade purpose. So I wrote a sample job when I actually found that, if treeNode is traversed all the way to fields and then property is modified and saved. The table still shows that it should to be saved (You can see a red horizontal line prefixed to the table name) Note: Although if you restore the table you can see the updated value. This gives an immersion to the user that that table needs to save manually else modified field properties value will be lost. Reason: To set a field property you need to traverse all the way to field node so the treeNode object actually holds the following buffer NAME: TreeNode VALUE: Path: \Data Dictionary\Tables\AddressCityTable_BR\Fields\CountryId:gls Due to which when treeNode.AOTSave () is performed the treeNode object try to perform the save on the field and not on the table. This was bit strange thing to observe in the first place. So to save the record I had to copy the treeNode instance to other object at the time of finding the table such that once the property is modified, the AOTSave/AOTCompile is made on the copied treeNode object. NAME: treeNode_TableName VALUE: Path: \Data Dictionary\Tables\AddressCityTable_BR Layer: gls By this way I was able to save the record successfully at run-time, without any manual intervention. Here is the sample code for the following exercise. X++: static void setTableProperties() { #AOT #Properties #define.tableName('AddressCityTable_BR') TreeNode treeNode; TreeNode treeNode_TableName; AOTTableFieldList aotFields; ; // Find the table using TreeNode. treeNode = infolog.findNode(#TablesPath).AOTfindChild(#tableName); // Copying the tables path because using this // INSTANCE we will save the AOT. treeNode_TableName = treeNode; // Go to the fields Node. aotFields = treeNode.AOTfindChild('Fields'); // Mention the field Name treeNode = aotFields.AOTfindChild('CountryId'); treeNode.AOTsetProperty(#PropertyMandatory, #PropertyValueNo); treeNode_TableName.AOTcompile(true); treeNode_TableName.AOTsave(); treeNode.treeNodeRelease(); treeNode = null; appl.dbSynchronize(tablenum(#tableName)); }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
![]() |
||||
Тема | Ответов | |||
Перечень пунктов меню и их свойств | 5 | |||
SysDictCoder: Changing properties of AOT objects in code | 0 | |||
Malaysia: How to Run Time Add Code to AOT | 0 | |||
Проблема с TreeNode | 4 | |||
treeNode | 3 |
|