14.09.2014, 04:56 | #1 |
Участник
|
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, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|