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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 02.04.2007, 16:50   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
casperkamal: Adding a Table field through X++ code in Dynamics Ax
Источник: http://casperkamal.spaces.live.com/B...CD63!258.entry
==============

 
   Sometime back there was a query in one of the discussion forum about inserting a table field through code. I did a small job to demonstrate that, just  thought would write that down in my blog too...... and here it is.
 
 
I have added sufficient comments to make it explanatory.   
   
 static void JobCreateTableFields(Args _args)
{
    #AOT
    #TreeNodeSysNodeType

    //find the Table
   
TreeNode                   tablenode = TreeNode::findNode(#TablesPath).AOTfindChild('LedgerTable');
    TreeNode                   fieldNode, tn;
    Struct                         properties;
    Struct                         propertyInfo;
    Array                          propertyArray;
    str                               propertyValue;
   
AOTTableFieldList    lst;
    str                               name;
    Counter                     propertyCount;
    int                               i;
    Map                            map = new Map(Types::String, Types::String);

    ;
 
    //Find the tables field node
   
lst = tablenode.AOTfindChild('fields');
    //add the field
    lst.addString('Test');
    //now find the node in the tree
    fieldNode  =  lst.AOTfindChild('Test');
    //get the properties structure
    properties = fieldNode.AOTgetPropertiesExt();
    //Update the properties map with the required properties
    map.insert('ExtendedDataType', 'LedgerAccount');

    // get the number of properties
    // and the array containing the properties structure
    propertyCount = properties.value('Entries');
    propertyArray = properties.value('PropertyInfo');

 
    for (i = 1; i < propertyCount; i ++)
    {
        propertyInfo  = propertyArray.value(i);
        name = propertyInfo.value('Name');
       
       
//see if we have inserted the property name in to the map
       
if (map.exists(name))
        {
           
//set the property
          
  propertyInfo.value('Value', map.lookup(name));
        }
    }


    //set the properties structure
    fieldNode.AOTsetPropertiesExt(properties);

    //save the treenode
    tablenode.AOTsave();
   
   
//Let us open the table
    //and see if the code works :)
    tablenode.AOTnewWindow();

 
click to download it from Axaptapedia
 
 
 ..........................    



Источник: http://casperkamal.spaces.live.com/B...CD63!258.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
За это сообщение автора поблагодарили: alex55 (1).
Старый 02.04.2007, 17:05   #2  
mazzy is offline
mazzy
Участник
Аватар для mazzy
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
29,472 / 4494 (208) ++++++++++
Регистрация: 29.11.2001
Адрес: Москва
Записей в блоге: 10
Цитата:
Сообщение от Blog bot Посмотреть сообщение
tablenode.AOTsave();
В этот момент поле запишется в тот слой, в котором в данный момент работает пользователь.

Если разработчик работает в слое cus, а пользователь в слое usr
И если код выполнит пользователь, то поле попадет в слой usr.
В результате разработчик не сможет удалить это поле пока не перейдет в слой usr.

А самое поганое, если помимо AOT'а информация о сохраняется где-то в базе.
Разработчик из базы удалить может, а из AOT'а нет, пока не перейдет в другой слой.

Были жуткие проблемы в российском модуле Расчеты с персоналом.
В этом модуле создание записи в таблице Группы времен приводит к автоматическому созданию поля в табелях.

Посмотрите какие проверки пришлось делать в этом модуле, чтобы не изменять идеологию... Не программируйте так.
__________________
полезное на axForum, github, vk, coub.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
casperkamal: Using record templates in code for Dynamics Ax 4.0. Blog bot DAX Blogs 0 10.05.2008 19:14
Inside Dynamics AX 4.0: Usage Scenarios Blog bot DAX Blogs 0 04.10.2007 05:15
Inside Dynamics AX 4.0: Inside the Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
casperkamal: A small addition to creation of Table throug x++ code in Dynamics Ax Blog bot DAX Blogs 0 03.04.2007 23:11
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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