AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.12.2010, 20:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
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));
}
Источник: http://axblog4u.wordpress.com/2010/1...-did-you-know/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Перечень пунктов меню и их свойств Sequel DAX: Программирование 5 09.08.2012 13:39
SysDictCoder: Changing properties of AOT objects in code Blog bot DAX Blogs 0 04.05.2009 20:05
Malaysia: How to Run Time Add Code to AOT Blog bot DAX Blogs 0 18.09.2007 15:00
Проблема с TreeNode sergeyoskol DAX: Программирование 4 01.08.2006 12:35
treeNode Novice DAX: Программирование 3 11.06.2003 12:38
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 03:17.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.