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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.09.2014, 04:56   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
How to add a new relation on a table from code
Источник: http://alexvoy.blogspot.com/2014/09/...able-from.html
==============

If you got into troubles, like me, trying to add a new relation on a table from X++, this code will save your day. The main point here is the code 251. Read my lips: two-five-one. Because reflections work on everything when you know the code.



private void createTableRelationInAOT(TreeNode _treeNodeTableRelation, TableName _relatedTableName, FieldName _relatedFieldName)
{
#Properties
TreeNode treeNodeRelations;
TreeNode tableRelation;
ReferenceNode tableRelationFields;

if(treeNodeTableRelation && _relatedTableName && _relatedFieldName)
{
treeNodeRelations = _treeNodeTableRelation.AOTfindChild(#PropertyRelations);
tableRelation = treeNodeRelations.AOTadd(relatedTableName);
tableRelation.AOTsetProperty('Table', relatedTableName);
//can anyone tell me how I could guess this secret code??
tableRelationFields = tableRelation.AOTaddSubNode(251);
//never change the order of two these properties! it works only like follows
tableRelationFields.AOTsetProperty(#PropertySecField, relatedFieldName);
tableRelationFields.AOTsetProperty(#PropertyRelatedField, relatedFieldName);
}
_treeNodeTableRelation.AOTsave();

}

Happy deciphering!


Источник: http://alexvoy.blogspot.com/2014/09/...able-from.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
atinkerersnotebook: Using the Dynamics AX Excel Add-In Blog bot DAX Blogs 1 25.09.2013 07:11
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
atinkerersnotebook: Using Service Management to Track Service Orders Blog bot DAX Blogs 1 25.08.2013 19:16
sashanazarov: How one new table relation may break your code somewhere Blog bot DAX Blogs 0 07.09.2012 14:11
Вопрос про Demand Planner slava09 DAX: Функционал 4 25.09.2006 11:43

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

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

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