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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.10.2017, 07:14   #1  
Blog bot is offline
Blog bot
Участник
 
19,472 / 657 (60) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: Customizing the Check Report via Extensions in Dynamics 365 for Operations
Источник: https://stoneridgesoftware.com/custo...or-operations/
==============

Recently I was asked to customize the Cheque_US report in Dynamics 365 for Operations. Based on this guidance from Microsoft I expected it to be a relatively easy and straightforward process. Here’s what I did to customize the check report via extensions:

  1. Duplicate the Cheque_US SSRS report to a model that extends the Application Suite model.
I called my new report MyCheque_US and added some text to indicate that it was the custom report—that way I could tell at a glance if I was looking at the stock report or my custom report.

  1. Create a new class MyChequeController that extends the ChequeController class in the same custom model.
Copy the main() method from ChequeController, and update it to use the report name for MyCheque_US:



class MyChequeController extends ChequeController { public static MyChequeController construct() { return new MyChequeController(); } public static void main(Args _args) { MyChequeController controller = new MyChequeController(); controller.parmArgs(_args); controller.deleteTempData(); //controller.parmReportName(controller.getChequeReport()); controller.parmReportName(ssrsReportStr(MyCheque_US, Report)); controller.parmShowDialog(false); controller.parmDialogCaption("@SYS24090"); controller.startOperation(); } }
  1. Extend the Cheque_US output menu item in the same custom model.
Set the Object property to refer to MyChequeController rather than ChequeController



I then compiled my solution and deployed the MyCheque_US report, and when I generated a payment everything worked! Well, almost everything: the custom report displayed as a blank page. I verified that if I switched back to the stock controller code controller.parmReportName(controller.getChequeReport()) then everything printed fine, but if I ran the same data through the MyCheque_US report it would fail every time.

After some digging I came to a startling conclusion. Based on its name and signature, I was trusting getChequeReport() to be a true accessor method:


When I inspected the method itself, though, it quickly became apparent that it was something very different:



/// /// Calls the initialize method and returns a cheque report type. /// /// /// A cheque report type. /// public SrsCatalogItemName getChequeReport() { this.init(); return chequeReport; }

ChequeController.getChequeReport() violates two method writing best practices: a method should do only one thing, and method names should reveal intention.

The giveaway that getChequeReport() does more than one thing is the “and” in the documentation summary. If you need to use the word “and” when describing what a method does, the method does too many things!

Admittedly, the method name getChequeReport does communicate what the method returns. The problem is that it doesn’t communicate everything that the method does. Had it instead been named initAndGetChequeReport then the intent of the method would be clear (and would clearly indicate that the method does too many things.)

In hindsight it would have been better to split getChequeReport() up into two methods, one to initialize the report and the other to retrieve the report name. In the end I decided that the least risky way to solve my problem was to keep the stock call to parmReportName() in place, and follow it up with another call to parmReportName() to direct execution to my custom report:



public static void main(Args _args) { MyChequeController controller = new MyChequeController(); controller.parmArgs(_args); controller.deleteTempData(); controller.parmReportName(controller.getChequeReport()); controller.parmReportName(ssrsReportStr(MyCheque_US, Report)); controller.parmShowDialog(false); controller.parmDialogCaption("@SYS24090"); controller.startOperation(); }

Now the report gets properly initialized, and my custom report design is used to generate the check.



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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: Configuring Power BI Integration for Dynamics 365 Workspaces Blog bot DAX Blogs 1 07.03.2017 10:04
stoneridgesoftware: Microsoft Dynamics 365 – Right around the Corner Blog bot DAX Blogs 0 10.10.2016 21:13
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 16 Blog bot Dynamics CRM: Blogs 0 23.01.2014 03:15
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 13 Blog bot Dynamics CRM: Blogs 0 27.03.2013 22:12
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 12 Blog bot Dynamics CRM: Blogs 0 30.01.2013 01:11
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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