Add shared CompanyMetadata data source for report layouts#9094
Add shared CompanyMetadata data source for report layouts#9094v-mortenr wants to merge 5 commits into
Conversation
5935848 to
617853f
Compare
Work item: AB#640703 Subscribe to the platform GetCompanyMetadata business event in ReportManagement and populate a shared company block (name, formatted address, phone/fax/email/ home page, bank, VAT/registration, giro, logo) from Company Information, so report layouts can bind one shared source instead of hand-coding company fields. - New Company Metadata Builder codeunit: typed setters centralize the wire keys (the subscriber never hand-writes raw key strings), including the address-line repeater and paired field captions. - CompanyDisplayName is sourced from the Company record (CompanyProperty.DisplayName, fallback to CompanyName) to match how the platform builds ReportRequest, not Company Information "Name 2". - Empty-safe: absent Company Information fields emit present-but-empty values. - Add Tests-Report coverage for values, captions, display-name source, empty-safe behavior, and the address repeater.
617853f to
f115f52
Compare
Add Company Metadata Builder.PopulateFromCompanyInformation to own the Company Information field -> wire-key mapping (name, formatted address, phone/fax/email/home page, VAT/registration, bank, and giro fields with their captions). ReportManagement.GetCompanyMetadata is now orchestration only: fetch the record, set the derived display name and logo, populate the block, and write. The emitted payload is unchanged. Prefix the new ReportManagement self-calls with this. (AA0248). Work item: AB#640703
Copilot PR ReviewIteration 2 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Sub-skills skipped
Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Codeunit 139596 was already used by the Shopify test app (ShpfyItemAttrAsOptionTest), which caused an object-ID conflict when the test apps are installed together. Move Company Metadata Test to 139593 (unused, next to the sibling Report Layouts Test). Work item: AB#640703
Bring in platform uptake (BCArtifact 29.0.52770.0) so CI can find the platform event this change depends on. See PR microsoft#9094.
The country build matrix failed in the test compile with AL0185 Codeunit 'Library Assert' is missing. CompanyMetadataTest (codeunit 139593) references codeunit 130002 "Library Assert", which is provided by the separate "Library Assert" app, not by the Assert codeunit (130000) already pulled in via Tests-TestLibraries. Declare the missing dependency, matching how sibling test apps (Tests-Job, Tests-Misc) reference it.
| /// </summary> | ||
| /// <param name="CompanyMetadata">The JSON object to merge the company payload into; existing keys with the same names are overwritten.</param> | ||
| [InherentPermissions(PermissionObjectType::TableData, Database::"Company Information", 'r')] | ||
| procedure GetCompanyMetadata(var CompanyMetadata: JsonObject) |
There was a problem hiding this comment.
GetCompanyMetadata declares [InherentPermissions(PermissionObjectType::TableData, Database::"Company Information", 'r')] as its only inherent grant, but the body's transitive call chain reads more than Company Information. PopulateFromCompanyInformation calls FormatAddress.Company(AddrArray, CompanyInfo), which calls the shared FormatAddr helper; when Company Information's Country/Region Code is blank it reads General Ledger Setup (GetGLSetup -> GLSetup.Get()), and when it is set it reads Country/Region (Country.Get(CountryCode)). Neither table is covered by the declared InherentPermissions, so a caller whose own permission set lacks read access to Country/Region or General Ledger Setup will hit a permission error inside this 'empty-safe' procedure. This is a new, unconditional cost: GetCompanyMetadata is wired as a static EventSubscriber on the platform's GetCompanyMetadata event, so it now runs on every report execution across the system (not just reports that previously called FormatAddress.Company), extending the permission surface report generation depends on. Align the InherentPermissions attribute with the procedure's actual transitive reads (add Country/Region and General Ledger Setup 'r', or restructure so FormatAddress's own permission needs are declared where the read happens).
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.15.4
Work item: AB#640703
Adds a shared CompanyMetadata data source so report layouts can bind one shared company block instead of each report hand-coding Company Information fields.
What
ReportManagementsubscribes to the platformGetCompanyMetadatabusiness event and populates the shared company block (name, formatted address repeater, phone/fax/email/home page, bank details, VAT/registration/giro, logo) fromCompany Information.Company Metadata Buildercodeunit (Access = Internal): typed setters centralize the wire keys so the subscriber never hand-writes raw key strings; includes the address-line repeater and the paired field captions.CompanyDisplayNameis sourced from the Company record (CompanyProperty.DisplayName(), falling back toCompanyName()) to match how the platform buildsReportRequest— not Company Information "Name 2".Tests-Reportcoverage for values, captions, the display-name source, empty-safe behavior, and the address repeater.