How to do it...

  1. Open your AL project in Visual Studio Code.
  2. In Explorer, create a new file named Customer Card Notification.al, and in Editor, create a new codeunit object:
codeunit 50108 "Customer Card Notification"{}
  1. In order to make the notification show, we must subscribe to OnAfterGetRecordEvent so that our notification will be evaluated when the customer record is retrieved from the database.

Add the following code to the codeunit object to create the subscriber:

[EventSubscriber(ObjectType::Page, Page::"Customer Card", 'OnAfterGetRecordEvent', '', false, false)]local procedure OnAfterGetRecordEvent(var Rec: Record Customer)begin    HandleCustomerCardNotification(Rec."No.");end;
  1. Now, let's create the function that shows the notification ...

Get Microsoft Dynamics 365 Business Central Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.