bc-table-dimensions-generator
Skill28 starsChanged 7 months agoMITView on GitHub
Adds Business Central standard dimension support to custom tables and their pages, following the DimensionManagement patterns used by Sales Header/Line, Job Journal Line and the repository Incident, Penalty and Work Worksheet modules. Generates Shortcut Dimension 1/2 Code fields (CaptionClass 1,2,N), the Dimension Set ID field, ValidateShortcutDimCode, ShowDimensions and ShowShortcutDimCode procedures, a card-page Dimensions group with all 8 shortcut dimensions whose visibility follows General Ledger Setup via DimMgt.UseShortcutDims, a Dimensions action, list-page global dimension columns, and default-dimension inheritance from master data (Resource, Customer, Vendor, Item, Job, Location, Employee) through CreateDimFromDefaultDim/GetRecDefaultDimID or a centralized GetDefaultDimID source-resolution procedure. Also covers header-to-line dimension inheritance and cascading. Use when adding dimensions to a custom table, making a custom document dimension-aware, showing shortcut dimensions on a page, controlling dimension visibility, or inheriting default dimensions from resources, customers or other master data.
In this repository38 other files it gives its agents.
- bc-agent-instructions-debuggerSkill
- bc-al-bug-fixSkill
- bc-al-code-reviewerSkill
- bc-al-project-contextSkill
- bc-api-page-generatorSkill
- bc-api-query-generatorSkill
- bc-approval-workflow-generatorSkill
- bc-attachments-generatorSkill
- skill-batch-processingSkill
- bc-business-events-generatorSkill
- bc-cds-page-generatorSkill
- bc-dataverse-entity-generatorSkill
- bc-dataverse-mapping-generatorSkill
- bc-field-propagationSkill
- bc-install-codeunit-generatorSkill
- bc-isolated-storage-generatorSkill
- bc-job-queueSkill
- bc-manifest-handoff-generatorSkill
- bc-matrix-page-generatorSkill
- bc-number-series-generatorSkill
- bc-pricing-refactorSkill
- bc-report-selection-generatorSkill
- bc-reportsSkill
- bc-setup-table-generatorSkill
- bc-setup-wizard-generatorSkill
- bc-telemetry-generatorSkill
- bc-test-codeunit-generatorSkill
- bc-upgrade-codeunit-generatorSkill
- documentation-bc-analysis-generatorSkill
- documentation-bc-architecture-generatorSkill
- documentation-bc-ccn-generatorSkill
- documentation-bc-md-to-docx-converterSkill
- documentation-bc-phase-plan-generatorSkill
- documentation-bc-release-note-generatorSkill
- documentation-bc-technical-spec-generatorSkill
- documentation-bc-user-story-generatorSkill
- onprem-remote-deploySkill
- skill-contribution-assistantSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Read these before generating.
- Distinctive: line 29
Ask the user (group into one question round):
- Very specific: line 41
Add "Shortcut Dimension 1 Code" (400), "Shortcut Dimension 2 Code" (401), "Dimension Set ID" (480).
- Very specific: line 51
Always add (template §2): ValidateShortcutDimCode, ShowShortcutDimCode, ShowDimensions.
- Very specific: line 70
Put ApplyDefaultDimensions(var Rec) + Get<X>DimensionSource(Rec) in the module Mgt codeunit.
- Very specific: line 71
Call it from the OnValidate of every field participating in the fallback chain (also the lower-priority ones, so clearing the primary falls …
- Very specific: line 75
Add an OnValidate that refreshes name fields before calling the dimension logic, and when master fields are set from code (imports, APIs, …
- Very specific: line 85
If the master field OnValidate changes dimensions, also refresh the array in the page field OnAfterValidate …
- Very specific: line 108
Do not assign master data fields directly in code when dimensions must follow.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
BC Table Dimensions Generator
Implements full dimension support on a custom table: fields, validation, page UI with visibility control, and default-dimension inheritance from master data.
Code templates: references/code-templates.md
Repository reference implementations
Read these before generating; mirror their style.
| Concern | File |
| Fields + procedures (lean) | src/incident/tables/PTEIncidentHeader.Table.al |
| Centralized inheritance with fallback | src/incident/codeunits/PTEIncidentMgt.Codeunit.al → ApplyDefaultDimensions, GetDimensionSourceResourceNo |
| Card Dimensions group + visibility | src/incident/pages/PTEIncidentCard.Page.al → SetDimensionsVisibility |
| Standard per-field inheritance | src/penalty/tables/PTEPenaltyHeader.Table.al → CreateDimFromDefaultDim, CreateDim, GetTableValuePair, InitDefaultDimensionSources |
| Header → line inheritance + cascade | src/webfleet/tables/PTEWorkWorksheetLine.Table.al (OnInsert), src/webfleet/codeunits/PTEWorkWorksheetMgt.Codeunit.al → CascadeDimensionsToLines |
| Archive / API exposure | src/penalty/tables/PTEPenaltyHeaderArchive.Table.al, src/penalty/pages/PTEPenaltiesAPI.Page.al |
Workflow
Step 1 — Gather inputs
Ask the user (group into one question round):
- Target table (name, ID, primary key field) and its card page / list page.
- Master data fields that must provide default dimensions, e.g.
"Customer No."→Database::Customer,"Vehicle Resource No."→Database::Resource. - Inheritance strategy (see Step 4): Standard merge (A) or Single source with fallback (B). If B, the ordered fallback list.
- Source code for Default Dimension Priorities (
SourceCodeSetup.Sales,.Purchases,.General, …). Default:SourceCodeSetup.Sales(repo convention). - Whether the table has lines that must inherit/cascade header dimensions.
Then verify field IDs 400, 401, 480 are free in the table (repo convention, aligned with standard documents). If taken, propose free IDs.
Step 2 — Table fields
Add "Shortcut Dimension 1 Code" (400), "Shortcut Dimension 2 Code" (401), "Dimension Set ID" (480). Template §1.
Rules:
CaptionClass = '1,2,1'/'1,2,2'so captions follow the actual global dimension names.TableRelationfiltered by"Global Dimension No."andBlocked = const(false).- Shortcut dimensions 3–8 are never stored as fields; they live only in the dimension set.
"Dimension Set ID"isEditable = false;OnLookupcallsShowDimensions();OnValidate(optional, used by Penalty) callsUpdateGlobalDimFromDimSetIDso API/import writes keep globals in sync.
Step 3 — Table procedures
Always add (template §2): ValidateShortcutDimCode, ShowShortcutDimCode, ShowDimensions. Declare DimMgt: Codeunit DimensionManagement as a global var.
Step 4 — Default dimension inheritance from master data
Choose with the user:
| Strategy | Behaviour | Use when |
| A. Standard merge (Penalty / Sales Line) | Every master-data field triggers CreateDimFromDefaultDim(FieldNo(...)). All sources are merged by GetRecDefaultDimID; conflicts resolved by Default Dimension Priorities for the source code. | Several sources contribute different dimensions (Customer → AREA, Resource → VEHICLE). |
| B. Single source with fallback (Incident) | One procedure resolves exactly one source (e.g. Vehicle, else Driver) and calls GetDefaultDimID. | Business rule says "one source wins" regardless of priorities. |
Strategy A (template §3):
OnValidateof each master field →CreateDimFromDefaultDim(Rec.FieldNo("<Field>")).InitDefaultDimensionSources: oneDimMgt.AddDimSource(DefaultDimSource, Database::<Table>, Rec."<Field>", FieldNo = Rec.FieldNo("<Field>"))per master field — all sources every time, so dimensions from untouched fields are kept.GetTableValuePair: onecasebranch per master field.CreateDim: clear globals,GetRecDefaultDimID(...),UpdateGlobalDimFromDimSetID(...).- Optionally call
CreateDimFromDefaultDimfromOnInsertif master fields can be set before insert without validation.
Strategy B (template §4):
- Put
ApplyDefaultDimensions(var Rec)+Get<X>DimensionSource(Rec)in the module Mgt codeunit. - Call it from the
OnValidateof every field participating in the fallback chain (also the lower-priority ones, so clearing the primary falls back correctly).
Both strategies replace manually entered dimensions when the master field changes — same as standard BC. State this to the user.
Add an OnValidate that refreshes name fields before calling the dimension logic, and when master fields are set from code (imports, APIs, workers) use Validate() so inheritance fires.
Step 5 — Card page
Template §5. Add:
group(Dimensions)with"Shortcut Dimension 1 Code","Shortcut Dimension 2 Code",ShortcutDimCode[3..8](page-variable fields withCaptionClass = '1,2,N',TableRelationon Global Dimension No. N,OnValidate→Rec.ValidateShortcutDimCode(N, ShortcutDimCode[N])) and a hidden"Dimension Set ID".- Each field
ApplicationArea = Dimensions; Visible = DimVisibleN;. - Action
Dimensions(Image = Dimensions,ShortCutKey = 'Alt+D') →Rec.ShowDimensions(); CurrPage.SaveRecord(); Rec.ShowShortcutDimCode(ShortcutDimCode);. OnOpenPage→SetDimensionsVisibility();OnAfterGetRecord→Rec.ShowShortcutDimCode(ShortcutDimCode);OnNewRecord→Clear(ShortcutDimCode).SetDimensionsVisibility: reset allDimVisible1..8to false, thenDimMgt.UseShortcutDims(DimVisible1, ..., DimVisible8). This hides any shortcut slot that is not configured in General Ledger Setup (Global Dimension 1/2 Code, Shortcut Dimension 3..8 Code).- If the master field
OnValidatechanges dimensions, also refresh the array in the page fieldOnAfterValidate(Rec.ShowShortcutDimCode(ShortcutDimCode)) or callCurrPage.Update()so slots 3–8 refresh immediately.
Step 6 — List page (optional)
Template §6. Add "Shortcut Dimension 1 Code" / "Shortcut Dimension 2 Code" columns with Visible = false (user personalizes). For visibility identical to the card, reuse DimVisible1/2 + SetDimensionsVisibility.
Step 7 — Lines, archives and APIs (when applicable)
- Lines (template §7): line
OnInsertcopies header"Dimension Set ID"+ globals when the line set is 0. HeaderValidateShortcutDimCode/ShowDimensionscallCascadeDimensionsToLines. For lines with their own master data, combine withInheritFromDimSetID = Header."Dimension Set ID"andInheritFromTableNo = Database::<Header>inGetRecDefaultDimID. - Archives / posted tables: same field IDs 400/401/480 so
TransferFieldscopies them; no validation triggers,ShowDimensionsusesDimMgt.ShowDimensionSet(read-only). - API pages: expose
dimensionSetId,shortcutDimension1Code,shortcutDimension2Code; keepdimensionSetIdread-only.
Step 8 — Validate
- Build and fix diagnostics.
- Translations: add XLF entries for new captions/tooltips if the repo translation workflow requires it.
- Tests (repo-native, under
test/<module>/): see checklist below.
Gotchas
- Forgetting
UpdateGlobalDimFromDimSetIDafter any Dimension Set ID change → globals out of sync with the set. - Shortcut 3–8 page fields are plain page variables: if
OnAfterGetRecorddoes not callShowShortcutDimCode, they show stale values when navigating records. GetRecDefaultDimIDneeds aSource Code Setuprecord — useGet()(strategy A) orif SourceCodeSetup.Get()(strategy B, test-friendly).- Do not assign master data fields directly in code when dimensions must follow; use
Validate. - In strategy A, always add every master source in
InitDefaultDimensionSources; adding only the changed field drops dimensions coming from the other fields.
Testing checklist
- Validating a master-data field with Default Dimensions fills
"Dimension Set ID"and globals. - Strategy A: two sources with conflicting dimension resolved by Default Dimension Priority.
- Strategy B: primary blank → fallback source used; both blank → set cleared.
- Editing Shortcut Dimension 3..8 on the card updates
"Dimension Set ID". ShowDimensionschange updates Shortcut 1/2 fields.- Card shows only shortcut slots configured in General Ledger Setup.
- Lines inherit header set on insert; header change cascades.
- Archive keeps the same
"Dimension Set ID".
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

