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

Опции темы Поиск в этой теме Опции просмотра
Старый 15.11.2020, 15:11   #1  
Blog bot is offline
Blog bot
23,561 / 800 (74) +++++++
Регистрация: 28.10.2006
vanvugt: How-to: Create Notifications – Steps to Take

In a recent VSCode/AL update training the topic notifications, as part of SaaSifying your solution, was tackled. After a short introduction of what these notifications (functionally) are about I explained and demoed how to develop them. Inviting the attendees thereafter to pose their questions, one of them, a seasoned C/SIDE developer whom I will call Bogdan, marked that he had been implementing them a couple of times and still had issues with the different parts that have to be developed. He asked: "Could you give me a clear overview on what steps I have to take?"

It was special to experience how this resonated i me as that was exactly what I ran into when preparing this part of the training. Notifications as a functional feature are efficient, simple and powerful. To code them isn't surely rocket science, but to have a clear overview what is needed and how it can be structured can indeed be somewhat muddy. Triggered by Bogdan's question I came up with the following steps:

  1. Create method NotificationId
  2. Create sender method
  3. Create recaller method
  4. Create method with send-or-recall logic
  5. Trigger send-or-recall method in event subscribers to relevant publishers
Let me elaborate on these steps by means of an example taken from Daniel Rimmelzwaan's video Develop SAAS user experiences for Dynamics 365 Business Central.

1.Create method NotificationId

Each notification should a unique id being a Guid. For reusibility ease of use you need to create a function that will allow you to assign and retrieve this id.

localprocedure NotificationId(): Guid;
Note that you have to fill in your own, unique Guid.

2.Create sender method

The code part that sets up your notification is called the sender. This is how it could look like:

localprocedure SendCompanyInfoMissingNotification()
CompanyInfoMissingNotification: Notification;
CompanyInfoMissingNotification.ID := NotificationId();
CompanyInfoMissingNotification.Message := CompanyInfoMissingNotificationMsg;
CompanyInfoMissingNotification.Scope := NotificationScope::LocalScope;
CompanyInfoMissingNotification.AddAction(OpenCompanyInfoTxt, Codeunit::"Notication Company Info", 'ShowCompanyInfomationWizard');
3.Create recaller method

Each sender should in general be accompanied by a recaller:

localprocedure RecallCompanyInfoMissingNotification()
CompanyInfoMissingNotification: Notification;
CompanyInfoMissingNotification.ID := NotificationId();
4.Create method with send-or-recall logic

Given sender and recaller we can now build the send-or-recall logic that will define whether a notification should be sent or recalled.

localprocedure SendOrRecallCompanyInfoMissingNotification()
CompanyInfo: Record "Company Information";
if (CompanyInfo.Name = '') or (CompanyInfo."E-Mail" = '') then
5.Trigger send-or-recall method in event subscribers to relevant publishers

Eventually, now having all logic in place to create a notification and determine to get it shown, the last part we need to setup is when it shouild be triggered.

[EventSubscriber(ObjectType::Page, Page::"Sales Order", 'OnAfterGetCurrRecordEvent', '', false, false)]
localprocedure CompanyInfoMissingNotifOnAfterGetCurrRecordEvent(var Rec: Record "Sales Header")
Hope this makes sense and can be of help.

Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
sertandev: How to receive D365FO push notifications using Azure Notification Hubs Blog bot DAX Blogs 0 04.07.2019 18:11
saurav-nav: NAV 2018 - Lots of New Objects! Blog bot NAV: Blogs 0 04.12.2017 10:11
vanvugt: How-to: Create a Workflow Template Blog bot NAV: Blogs 0 15.05.2016 18:12
Van Vugt: How-to: Create a Workflow Template Blog bot Dynamics CRM: Blogs 0 27.12.2015 17:00
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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