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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.04.2019, 20:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
stoneridgesoftware: How to Place Custom Code Using Events in Microsoft Dynamics NAV 2016
Источник: https://stoneridgesoftware.com/how-t...mics-nav-2016/
==============

With every modification to Microsoft Dynamics NAV we are faced with the tough question, where should I place this new code? Do we place it directly on the page? The action on the page? The table the page references? Or a code unit? This may seem like a minuscule decision but if your company repeatedly makes the wrong decision, you will accumulate a tremendous amount of technical debt. This causes upgrades and future modifications to substantially increase in time, difficulty and overall cost.

Avoiding altering base NAV functionality will make your upgrades faster and less painful. Microsoft has helped developers with this by introducing events in NAV 2016. Events utilize a hooking pattern that allows developers to add their modifications without touching base NAV code.

In this example, we are going to set up an Event to run after we release a sales order.

Steps:
  1. Create a custom code unit to store your events.
  2. Create your function and set the property Event to Subscriber
    1. Publisher: Allows you to create a new Event. Objects comes with stock events, however, if you need to create custom events you would set your function to Publisher.
    2. Subscriber: Is called when Events are triggered.
      • For this example, after a sales order is successfully released, our code in this newly created Event Subscriber will run.
Setting a function to Subscribe to an Event
  • Set the Event to Subscriber
  • Set the EventPublisherObject to Codeunit 414, Release Sales Document
  • Set the EventFunction to OnAfterReleaseSalesDoc


This message will appear, click Yes. This will change your event subscriber function parameters for you.



You can now add custom code to your new Event Subscriber function.



Here you can see our Event Subscriber running after you click release.



Going back to our original question, where should we place custom modification code? We recommend placing customizations in custom code units utilizing events to avoid making modifications in base NAV code. This will minimize your company’s technical debt and allow for more cost-efficient upgrades and future modifications.

If you are a Dynamics NAV user and have more questions, contact the team at Stoneridge Software for additional help.



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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: Changes to Microsoft Dynamics NAV Change Log System: How to Revert its Behavior Blog bot NAV: Blogs 0 23.06.2016 20:13
NAV Team: Upgrading from Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 to Microsoft Dynamics NAV 2015 Blog bot Dynamics CRM: Blogs 0 23.02.2015 13:00
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 17 Blog bot Dynamics CRM: Blogs 0 10.05.2014 06:30
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 7 Blog bot Dynamics CRM: Blogs 0 27.03.2012 02:11
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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