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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 29.09.2017, 07:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Using the new Chain of Command feature in X++
Источник: https://stoneridgesoftware.com/using...-feature-in-x/
==============

Recently a new feature for X++ developers was announced from Michael Fruergaard Pontoppidan (MFP) called Chain of Command. I knew I would want to try it out as soon as I had some time and it is pretty slick. This post will show it in action with a simple example in Microsoft Dynamics 365 Enterprise edition (AX7).

Syntax Requirements

My example is nothing flashy. It shows how to raise an Infolog message when a sales line is added to a sales order and the customer does not have a credit rating. Since I know that when you add a sales line, the SalesLineType class is called and the insert method is used. My plan was to create an extension for the SalesLineType class and put custom code in the insert method. Here is the code for the new extension class:

X++:
[ExtensionOf(classStr(SalesLineType))]
final class SalesLineType_Extension
{
    public void insert(boolean dropInvent, boolean findMarkup, Common childBuffer, boolean _skipCreditLimitCheck)
    {
        CustTable   custTable;        
        
        //get customer for evalation of credit rating
        custTable = CustTable::find(salesLine.CustAccount);
 
        if(!custTable.CreditRating)
        {
            info("Customer on sales line has no credit rating!");
        }
 
        // must call next when using Chain of Command pattern
        next insert(dropInvent, findMarkup, childBuffer, _skipCreditLimitCheck);        
    }
 
}
Note the usage of the ExtensionOf attribute and the requirement to use the next keyword. The compiler told me to mark the class final so I did that also. Since the insert method in the SalesLineType class is public, I also had to use public in the extension class.
For reference, here is my project which is based on a new package in Visual Studio:



Here is the Infolog when saving a new sales line:



Debugging Tip

One issue I ran into was around debugging with Visual Studio. The symbols would not load for my breakpoints. To resolve this, I marked the below setting in the Visual Studio debugging options. In addition to this one, there is also a similar setting in the Dynamics 365 node.



Chain of Command was released with Platform Update 9. You can find more information in this “What’s New or Changed in Dynamics 365 for Finance and Operations” article.





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

Последний раз редактировалось mazzy; 29.09.2017 в 10:49.
Теги
chain of command

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: PrecisionForms for Document Management in Dynamics AX Blog bot DAX Blogs 0 14.09.2017 19:11
stoneridgesoftware: Update Report Formats using Microsoft Word – Dynamics NAV 2017 Blog bot NAV: Blogs 0 18.08.2017 00:12
stoneridgesoftware: Part I: Configuring the Dynamics AX 2012 R3 Entity Store Blog bot DAX Blogs 0 27.04.2017 12:11
stoneridgesoftware: How to Integrate Power BI with Dynamics 365 for Financials Blog bot DAX Blogs 0 01.04.2017 02:17
stoneridgesoftware: Email Alerts on Power BI Dashboards with Microsoft Flow – Better Together Blog bot DAX Blogs 0 19.01.2017 20:11

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

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

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