Run logic before the UI loads. This hook gives you the power.
Yo! Still building the LearnBeyondBC home base, just a few bricks away from our thousand-piece LEGO masterpiece. If you’re reading this, you’re helping place one.
Since you’re here for another tutorial and learning above and beyond BC, I just want to say: I love seeing you here. Let’s dive into this week’s #BCSaturdayCodeHacks.
If you’ve been following the series (which started almost two months ago), you know I’m obsessed with modularity, mythic UX and aesthetics (Artisan thing). This week’s brick? A quiet powerhouse: Codeunit 1430 – Role Center Notification Mgt.
The Problem We’re Solving
Back when I was refining onboarding flows in my previous engagements, I kept hitting a wall: How do you run logic before the Role Center fully loads? I needed a way to trigger background tasks, send alerts, and apply personalization without blocking the user or relying on page-level events.
That’s when I discovered Codeunit 1430 – Role Center Notification Mgt. It’s a subtle but powerful entry point for customizing the startup experience.
Introduction: What’s the Deal with Codeunit 1430 or "Role Center Notification Mgt."?
Role Center Notification Mgt. is a system codeunit that lets you hook into the Role Center before it fully loads. It exposes the event OnBeforeShowNotifications, which runs before the Role Center UI renders: Yes, you heard that right—pre-render logic. Perfect for:
- Send non-blocking notifications
- Trigger background logic
- Apply personalization settings
- Prepare the environment silently
Where This Shines
- Onboarding Flows: Show welcome messages, tips, or send non-blocking alerts (Teaser post incoming—HAHAHAHAHAH)
- Diagnostics: Log user context or telemetry
- Personalization: Trigger role-based logic (e.g., check if a profile has a feature flag)
- Background Tasks: Load data silently—just like Microsoft does when creating a company and offering sample Contoso data
- Custom Setup: We use this to load sample data and default setups from our Azure Blob Storage
Our Not So Boooooooooooooooooooooooring Part (Coding)
This event runs before the Role Center UI renders. Here’s how you can subscribe to it:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Role Center Notification Mgt.", 'OnBeforeShowNotifications', '', false, false)]
local procedure CodeunitRoleCenterNotificationMgtOnBeforeShowNotifications()
begin
// Send non-blocking system notifications
// SendSystemNotifications();
// Example: Notify user of system status or updates
// Execute background initialization tasks
// RunBackgroundTasks();
// Example: Load demo data or default setups from external sources
// Apply user-specific personalization settings
// ApplyUserPersonalization();
// Example: Apply feature flags or user preferences
// Reserved for future startup routines
// ExecuteStartupExtensions();
end;
Demo Scenario
Upon loading the Role Center, we’ll inject demo customer data using our featured codeunit. This is a straightforward showcase, no duplicate flagging or validations here. The goal is to demonstrate how easily demo data can be seeded through modular code.
Step 1
Create a codeunit that handles the event subscription. Subscribe to the OnBeforeShowNotifications event from the Role Center Notification Mgt. codeunit.
codeunit 50106 "JB Event Subscribers"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Role Center Notification Mgt.", 'OnBeforeShowNotifications', '', false, false)]
local procedure CodeunitRoleCenterNotificationMgtOnBeforeShowNotifications()
var
EventHandler: Codeunit "JB Event Handler";
begin
EventHandler.HandleCodeunitRoleCenterNotificationMgtOnBeforeShowNotifications();
end;
}
Step 2
Create a dedicated handler codeunit that responds to the event raised in your subscriber codeunit. Inside this handler, call the InvokeDemoCustomerSetup function to execute your customer creation flow.
procedure HandleCodeunitRoleCenterNotificationMgtOnBeforeShowNotifications()
begin
InvokeDemoCustomerSetup();
end;
Step 3
This procedure handles dynamic customer creation using the provided parameters. It’s called from our setup routine to inject demo data into the system.
local procedure SetupDemoCustomer(CustomerNo: Code[20]; CustName: Text[100]): Boolean
var
Customer: Record Customer;
begin
Customer.Init();
Customer."No." := CustomerNo;
Customer.Name := CustName;
Customer."Is Demo" := true;
exit(Customer.Insert(true));
end;
Step 4
We start by generating a list of names and storing them in a [DataType] structure. For each entry, we invoke the dynamic customer creation routine. At the end, a confirmation page appears, offering to open the newly created customer, mirroring the UX flow of converting a quote to an order.
local procedure InvokeDemoCustomerSetup()
var
Customer: Record Customer;
ConfirmMgt: Codeunit "Confirm Management";
i: Integer;
OpenNewCustomerQst: Label '%1 New customers created. Do you want to open customer card?', Comment = '%1 - No. of new customer';
CustomerNames: List of [Text[100]];
CustomerName: Text[100];
begin
CustomerNames.Add('Isshin Ashina');
CustomerNames.Add('Aden Pierce');
CustomerNames.Add('Jeffrey Bulanadi');
CustomerNames.Add('Taylor NotTooWell');
CustomerNames.Add('Mr. P Sherman');
CustomerNames.Add('John Doe');
CustomerNames.Add('Juan Lazy');
CustomerNames.Add('Mad Afaka');
foreach CustomerName in CustomerNames do
if SetupDemoCustomer(GenerateCustomerNo(), CustomerName) then
i += 1;
// Keeping it simple for now—don’t want to spoil the magic of our next #BCSaturdayCodeHacks
GetDemoCustomers(Customer);
if i > 0 then
if ConfirmMgt.GetResponseOrDefault(StrSubstNo(OpenNewCustomerQst, i), true) then
Page.Run(Page::"Customer List", Customer);
end;
Step 5
That wraps up the core logic. There are many potential use cases for this approach, from demo setups to onboarding flows and beyond. Feel free to explore and adapt it to your needs.
Best Practices I Can Vouch For
- Keep startup logic lightweight, avoid blocking calls
- Centralize notification logic in a helper codeunit
- Use LocalScope for user-specific messages
- Avoid UI dependencies, this runs before rendering
- Log startup actions for diagnostics and support
Gotchas We’ve Hit (and How to Outsmart Them)
- No access to page context, don’t rely on UI elements
- Avoid long-running logic—it can delay Role Center load
- Notifications must be scoped properly to avoid confusion
- This event runs every time the Role Center loads, use flags if needed
Let’s move from theory to practice. Time for the demo. ✨
Pro Tips I Can Vouch For
Use this hook to silently check for updates, validate user roles, or preload data for dashboards, without interrupting the user. It’s perfect for modular startup logic.
TL;DR & What’s Next
This week, we explored how to hook into the Role Center using OnBeforeShowNotifications. Next Saturday, we’ll go deeper into non-blocking notifications, how to route them, attach actions, and build contextual alerts.
♻️ Repost to support the community and follow Jeffrey Bulanadi for clear, technical insights above and beyond Business Central and AL development.
Demo Repository: Explore my GitHub sample showcasing Role Center–specific logic in AL: Role Center Notification Mgt. on GitHub
Helpful Reference
Role Center Notification Mgt. – System Codeunit
EventSubscriber Attribute – Microsoft Learn
#BCSaturdayCodeHacks #learnbeyondbc #Dynamics365 #MSDyn365 #MSDyn365BC #BusinessCentral #ALDevelopment #ALDev #DevTips #ConsultingLife #LearningBCNotSoBoringSeries
Join the Conversation
Share your thoughts, ask questions, or discuss this article with the community. All comments are moderated to ensure quality discussions.
Loading comments...
No comments yet
Be the first to start the conversation!
0 Comments
Leave a Comment