Skip to the content

News

Live Schedule for December

After a lot of fun with interfaces on Friday, I’ve received a lot of very encouraging feedback. It seems that the decision to start live video blogging was right, and I am sticking with it.…

The post appeared first on .

How to test Business Central webhooks

I don’t think webhooks need an introduction. But for those who are new to the topic, here you can find the official documentation. In short, a webhook is a push notification. The “don’t call us, we’ll call you” scenario of ...

Fun with Interfaces

Today I’ve streamed the Fun with Interfaces video blog at https://www.youtube.com/watch?v=QSMHL32c5mg and the recording is now published online. This was the first session I ever delivered about interfaces, and I actually planned delivering this a…

The post appeared first on .

Add Bookmarks via AL Code

Add Bookmarks via AL Code Using the bookmark icon , you can add an action that opens a page or report from the navigation menu of your Role Center. The bookmark icon is shown in the top right corner of a page and also in the Tell Me window where you can efficiently bookmark multiple pages or ...

L'articolo proviene da .

Understanding renaming/moving files with git

Source code files are living things. We add new ones and change their content on daily basis. Occasionally we delete them, too. Git is amazingly efficient when it comes to tracking these kinds of changes.…

The post appeared first on .

How to replace DotNet in AL

A lot of us still have a ton of C/AL code sitting around in existing databases that sooner or later will have to be moved into AL. A lot of us also have a ton…

The post appeared first on .

Business Central Virtual Entities and CDS

Business Central Virtual Entities and CDS God morning, It’s been a while since I wrote and I disappeared from the communities because I was sick, Covid unfortunately hit me too. After about 17 days of severe illness, I am slowly recovering, now I feel better. Covid is a disease that I do NOT recommend to ...

L'articolo proviene da .

Migrating Control Add-ins from C/SIDE to AL

Thanks to everyone who watched my live stream today! The audience wasn’t big, but it’s a very narrow topic, not of broad interest. Still, I am glad I got a few interesting questions that actually…

The post appeared first on .

How-to: Add your notification to My Notifications

In my post I introduced a step-by-step recipe that can help you to efficiently create a (non-intrusive) notification. I gladly used the YouTube video by Daniel Rimmelzwaan to illustrate this. Doing this I stuck to his example without adding anything, but the step-by-step approach.

In this post I would like to extend the example allowing you to add your notification to My Notifications and enabling the user to turn on or off your notification. To achieve this I need to do three additional steps, continuing the numbering of the steps as introduced in .

  1. Add notification to My Notifications
  2. Create IsEnabled check method
  3. Call IsEnabled in send-or-recall method

6. Add notification to My Notifications

A notification is being added to My Notifications based on the . This can easily be achieved with a subscriber to the OnInitializingNotificationWithDefaultState publisher on the My Notifications page.

[EventSubscriber(ObjectType::PagePage::"My Notifications", 'OnInitializingNotificationWithDefaultState''', false, false)]
local procedure OnInitializingNotificationWithDefaultState()
var
    MyNotifications: Record "My Notifications";
begin
    MyNotifications.InsertDefaultWithTableNum(NotificationIdLbl,
        CompanyInfoMissingNotificationMsg,
        CompanyInfoNotificationDescriptionTxt,
        Database::"Company Information");
end;

Note that we reuse the NotificationIdLbl  and CompanyInfoMissingNotificationMsg labels already created as part of the previous steps and that an additional label is needed.

var
    CompanyInfoNotificationDescriptionTxt: Label 'Show warning when the company information is not complete.';

7. Create IsEnabled check method

We need a method that determine whether the notification is enabled or not (by the user).

local procedure IsCompanyInfoNotificationEnabled(CompanyInfo: Record "Company Information")Boolean
var
    MyNotifications: Record "My Notifications";
begin
    exit(MyNotifications.IsEnabledForRecord(NotificationIdLbl, CompanyInfo));
end;

8. Call IsEnabled in send-or-recall method

And finally we need to call the IsEnabled method by adding the following tow lines to the SendOrRecallCompanyInfoMissingNotification methodthat was created in after the company record was gotten.

if not IsCompanyInfoNotificationEnabled(CompanyInfothen
    exit;

Now you have a complete action plan to create a notification and enable the user to configure whether it will appear or not. Have fun.

How-to: Add your notification to My Notifications (1)

In my post I introduced a step-by-step recipe that can help you to efficiently create a (non-intrusive) notification. I gladly used the YouTube video by Daniel Rimmelzwaan to illustrate this. Doing this I stuck to his example without adding anything, but the step-by-step approach.

In this post I would like to extend the example allowing you to add your notification to My Notifications and enabling the user to turn on or off your notification. To achieve this I need to do three additional steps, continuing the numbering of the steps as introduced in .

  1. Add notification to My Notifications
  2. Create IsEnabled check method
  3. Call IsEnabled in send-or-recall method

6. Add notification to My Notifications

A notification is being added to My Notifications based on the . This can easily be achieved with a subscriber to the OnInitializingNotificationWithDefaultState publisher on the My Notifications page.

[EventSubscriber(ObjectType::PagePage::”My Notifications”, ‘OnInitializingNotificationWithDefaultState’, false, false)]
local procedure OnInitializingNotificationWithDefaultState()
var
    MyNotifications: Record “My Notifications”;
begin
    MyNotifications.InsertDefaultWithTableNum(NotificationIdLbl,
        CompanyInfoMissingNotificationMsg,
        CompanyInfoNotificationDescriptionTxt,
        Database::”Company Information”);
end;

Note that we reuse the NotificationIdLbl  and CompanyInfoMissingNotificationMsg labels already created as part of the previous steps and that an additional label is needed.

var
    CompanyInfoNotificationDescriptionTxt: Label ‘Show warning when the company information is not complete.’;

7. Create IsEnabled check method

We need a method that determine whether the notification is enabled or not (by the user).

local procedure IsCompanyInfoNotificationEnabled(CompanyInfo: Record “Company Information”)Boolean
var
    MyNotifications: Record “My Notifications”;
begin
    exit(MyNotifications.IsEnabledForRecord(NotificationIdLbl, CompanyInfo));
end;

8. Call IsEnabled in send-or-recall method

And finally we need to call the IsEnabled method by adding the following tow lines to the SendOrRecallCompanyInfoMissingNotification methodthat was created in after the company record was gotten.

if not IsCompanyInfoNotificationEnabled(CompanyInfothen
    exit;

Now you have a complete action plan to create a notification and enable the user to configure whether it will appear or not. Have fun.

Update 20201119

Waldo has added this a a snippet tmynotificationscodeunitwaldo to his CRS AL Language Extension.