bcquality/microsoft/knowledge/style/named-invocations-not-object-ids.md
Jesper Schulz-Wedde b6da405376 Improve partner onboarding and documentation navigation
Lead with a complete plugin quick start and add task-oriented usage, troubleshooting, customization, and contribution guides. Preserve the broader plugin framing, correct conflicting contract guidance, support Agents folder reviews, and align repository validation. Convert existing sample references to clickable links without changing knowledge rules.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-09 17:25:29 +02:00

1.7 KiB

bc-version domain keywords technologies countries application-area
all
style
page
report
codeunit
runmodal
run
object-id
named-invocation
al
w1
all

Call objects by name, not by numeric ID

Description

Page.RunModal, Report.Run, Codeunit.Run, and the Page::, Report::, Codeunit::, Table::, XmlPort:: selectors accept either a numeric ID or a named alias. The named form — Page::"Posted Sales Shipment Lines", Report::"Sales - Invoice" — is the one to use. Numeric IDs are an implementation detail that change with renumbering, do not survive a rename, and carry no signal to a reader about what the call actually does. The compiler resolves named aliases at build time, so the named form is no slower than the numeric form.

Best Practice

When invoking an object whose named alias is available in the same app (or in a dependency the current app already references), use the named form: Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine), Report.Run(Report::"Sales - Invoice", true). The same applies to Codeunit.Run, XmlPort.Run, Query.Open, and any platform method that takes an object reference. The named form makes diffs reviewable — a rename is visible — and makes log output and stack traces interpretable.

See sample: named-invocations-not-object-ids.good.al.

Anti Pattern

Page.RunModal(525, …) or Report.Run(206, true). The numeric form is unreadable, fragile across renumbering, and breaks every search that looks for callers of a named object.

See sample: named-invocations-not-object-ids.bad.al.