BCQuality rule · performanceAL Developmentofficial - Microsoftderived - from the source, no model text

Compute data-driven Role Center headlines in the background, not when the page opens

Code in a headline part's OnOpenPage, or in a subscriber to an event raised from it, runs every time the Role Center opens. When that code loops over documents or ledger entries, every Role Center open pays for work that grows with transaction volume.

Rule on GitHub · microsoft layer · performance · BC all · tier official · derived

Description

Code in a headline part’s OnOpenPage, or in a subscriber to an event raised from it, runs every time the Role Center opens. When that code loops over documents or ledger entries, every Role Center open pays for work that grows with transaction volume.

Base App’s Headline RC ... pages (for example page 1441 "Headline RC Order Processor") provide background infrastructure for headlines added through page extensions. Their OnOpenPage calls "RC Headlines Page Common".HeadlineOnOpenPage, which schedules codeunit 1441 "RC Headlines Executor" (TableNo = "Job Queue Entry") through "Job Queue - Enqueue". The executor’s OnRun reads the opening user’s "RC Headlines User Data" record (Get(UserSecurityId(), ...)) and raises OnComputeHeadlines(RoleCenterPageID). The same HeadlineOnOpenPage raises OnIsAnyExtensionHeadlineVisible; a subscriber that sets it to true hides the page’s default documentation headline. Microsoft’s Essential Business Headlines app computes in OnComputeHeadlines, stores results per user in "Ess. Business Headline Per Usr", and only reads that table on the page side. The AL Guidelines (NAV Design Patterns) article describes the same split and says “The computation is done in a background task, not to decrease the performance of the role center pages”. Microsoft Learn does not document these events.

Microsoft’s own code does not always follow this. "Headline RC A/P Admin", a Base App HeadlinePart page, loops over three months of vendor ledger entries in its OnOpenPage.

Best Practice

For a headline added to a Base App Headline RC ... page whose content comes from iterating documents or entries:

  1. Subscribe to OnComputeHeadlines on Codeunit::"RC Headlines Executor", filter on RoleCenterPageID, compute, and store the result per user (UserSecurityId()).
  2. Subscribe to OnIsAnyExtensionHeadlineVisible on Codeunit::"RC Headlines Page Common" and set ExtensionHeadlinesVisible := true only when a stored headline is visible. Do not set it to false; Microsoft’s subscriber comments that this “could overrride some other extensions setting the value to true”.
  3. In the page extension’s OnOpenPage, read the stored text and visibility.

Expect the trade-off: a headline appears only after the job has run. HeadlineOnOpenPage requests a refresh at most once an hour per user, and ScheduleTask does not enqueue when a Ready or In Process entry already exists for that Role Center, or restarts a failed or on-hold entry the next day. Nothing is computed when the job cannot be scheduled, for example without Job Queue permissions.

A headline on your own HeadlinePart page has no executor event. Run that work in a page background task; Learn lists HeadlinePart among the part pages that support them, and notes that a part page shows dashes for its fields until all of its background tasks complete. See page-background-tasks-for-expensive-cues.md.

See sample: compute-role-center-headlines-in-the-background.good.al.

Anti Pattern

A headline page extension’s OnOpenPage, a subscriber to its visibility event, or a HeadlinePart page’s OnOpenPage loops over documents or ledger entries (FindSet with repeat ... until Next() = 0) or runs a query to build headline text. See sample: compute-role-center-headlines-in-the-background.bad.al.

Not this pattern:

  • The same loop in an OnComputeHeadlines subscriber or in a page background task codeunit.
  • Static text, or visibility from a setup or availability check. Microsoft’s Connectivity Apps banking headline does this in OnOpenPage.
  • A FlowField or CalcSums aggregate computed once per page instance. Microsoft’s Sustainability headline part calculates cue FlowFields for today and yesterday this way.

References

Examples

Names

Changed by


From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).