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.
- microsoftlayer
- performancedomain
- 2examples
- 1pull request
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:
- Subscribe to
OnComputeHeadlinesonCodeunit::"RC Headlines Executor", filter onRoleCenterPageID, compute, and store the result per user (UserSecurityId()). - Subscribe to
OnIsAnyExtensionHeadlineVisibleonCodeunit::"RC Headlines Page Common"and setExtensionHeadlinesVisible := trueonly when a stored headline is visible. Do not set it tofalse; Microsoft’s subscriber comments that this “could overrride some other extensions setting the value to true”. - 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
OnComputeHeadlinessubscriber 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
CalcSumsaggregate computed once per page instance. Microsoft’s Sustainability headline part calculates cue FlowFields for today and yesterday this way.
References
- RCHeadlinesExecutor.Codeunit.al:
TableNo(line 7),OnRunwith the userGetat 15 andOnComputeHeadlinesat 17,ScheduleTask(21-53; pending-entry check 29-34, next-day restart 36-40), event (72-75). RCHeadlinesPageCommon.Codeunit.al:HeadlineOnOpenPage(15-41), one-hourShouldCreateAComputeJob(49-57),ComputeDefaultFieldsVisibility(59-66),OnIsAnyExtensionHeadlineVisible(104-107). - Essential Business Headlines: EssBusHeadlineSubscribers.Codeunit.al (
OnComputeHeadlines55-93,OnIsAnyExtensionHeadlineVisible95-139 with the comment at 136,OnSetVisibility192-204), HeadlinesRCOrderProcExt.PageExt.al (59-68). - Inline in Microsoft code: HeadlineRCAPAdmin.Page.al (
OnOpenPage89-96,FindVendorLedgerEntryWithMaxAmountInLastQuater119-143); Connectivity Apps HeadlineRCAccountantExt.PageExt.al (35-42); Sustainability RCHeadlinePageSust.Codeunit.al (18-55). - Page Background Tasks, section “Designing part pages for page background tasks”. Creating a Role Center headline.
- Extending the Role Center Headlines, AL Guidelines (NAV Design Patterns) article by David Bastide at Microsoft Development Center Copenhagen, from the April 2018 release (steps at line 46-49). Its event locations are outdated: it places
OnComputeHeadlineson a codeunit per headline page, without theRoleCenterPageIDparameter.
Examples
- Good: compute-role-center-headlines-in-the-background.good.al
- Bad: compute-role-center-headlines-in-the-background.bad.al
Names
- Record.CalcSums(Any [, Any,…]) Method (names CalcSums)
- RecordId.TableNo() Method (names TableNo)
- page 1441 “Headline RC Order Processor” (possibly related: a code span names it)
- codeunit 1441 “RC Headlines Executor” (possibly related: a code span names it)
- codeunit 453 “Job Queue - Enqueue” (possibly related: a code span names it)
- table 1458 “RC Headlines User Data” (possibly related: a code span names it)
- table 1436 “Ess. Business Headline Per Usr” (possibly related: a code span names it)
- page 9049 “Headline RC A/P Admin” (possibly related: a code span names it)
Changed by
From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).