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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 10.02.2017, 19:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Using X++ to Find if an Object Exists in the Current Model
Источник: https://stoneridgesoftware.com/using...current-model/
==============

I recently had a scenario where I needed to verify programmatically whether or not an AOT element exists in the current model. This is a very simple task if you are manually looking at an object in the AOT, but it isn’t so easy to do in X++. The issue you run into is – if the object exists initially in the Foundation model (in the sys layer) and you add to it in the usr layer portions of the AOT element exist in the Foundation model and the particular piece you added exists in a different model. For example, on a table created in the sys layer beside the table name is the model Foundation. If you add a method to the table, beside the name of the method you see your model’s name. If you use the TreeNode class to identify which model the table exists in, it will tell you the model the currently selected node is in. So if you are on the table’s name node, you will get the Foundation model. If you happen to be on the node of the method you added, TreeNode will return the model the method exists in. The X++ code below will find the first node in the AOT element that exists in the current model and layer.

For example, on a table created in the sys layer beside the table name is the model Foundation. If you add a method to the table, beside the name of the method you see your model’s name. If you use the TreeNode class to identify which model the table exists in, it will tell you the model the currently selected node is in. So if you are on the table’s name node, you will get the Foundation model. If you happen to be on the node of the method you added, TreeNode will return the model the method exists in. The X++ code below will find the first node in the AOT element that exists in the current model and layer.

SysModelElement element, childElement; SysModelElementData elementData, childElementData; SysModelLayer layer; SysModelManifest model; TreeNode node = TreeNode::findNode(@"\Data Dictionary\Tables\Accountant_BR"); //Find the root node for this AOT element select element join elementData where elementData.ModelElement == element.RecId join model where model.RecId == elementData.ModelId && element.Name == node.AOTname() && element.ElementType == xUtilIdElements::findTreeNode(node).recordType; //Find anything on this element //in the current layer and model select firstOnly childElement join childElementData where childElementData.ModelElement == childElement.RecId && childElement.RootModelElement == element.RootModelElement join layer where layer.RecId == childElementData.Layer && layer.Layer == enum2int(currentAOLayer()) join model where model.RecId == childElementData.ModelId && model.Model == xInfo::getCurrentModelId();



Источник: https://stoneridgesoftware.com/using...current-model/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: Email Alerts on Power BI Dashboards with Microsoft Flow – Better Together Blog bot DAX Blogs 0 19.01.2017 20:11
stoneridgesoftware: Microsoft Dynamics AX Error: The Record Already Exists Blog bot DAX Blogs 0 12.07.2016 18:12
stoneridgesoftware: TFS Code Repository and Dynamics AX Blog bot DAX Blogs 0 16.06.2016 16:11
Navigate Into Success: Detecting current object type and ID using some funky .NET Interop Blog bot Dynamics CRM: Blogs 0 04.09.2014 11:00
How to find your object in AOT projects Blog bot DAX Blogs 0 03.05.2011 06:15
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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