/bc-word-layout:al-word-layout-designfrom BC Word Layout
Guides designing Business Central Word report layouts before editing tools are used. Covers two archetype skeletons (trading document, list/analysis report), BC design conventions for address blocks, captions, line tables, totals, and typography.
Ships in BC Word Layout. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A prompt like "create a new layout for Purchase Order" leaves every design decision open, and
validate_layout cannot catch a bad answer: a structurally valid, fully bound, ugly document
passes level=full with zero findings. This skill closes that gap with the conventions a BC Word
layout is expected to follow. Every claim is tagged with its evidence:
tests/corpus/ (document-shaped: Standard
Sales Quote 1304, Standard Purchase Order 1322, Standard Sales Invoice w. VAT Spec 1306, Standard
Statement 1316; list-shaped: Salesperson Commission 115, Job Quote 1016).docs/FIDELITY-CHECKLIST.md cites).Everything here is a default, not a law: explicit user requirements always win, and where the
stock layouts disagree with each other this skill says so rather than inventing a rule. Maintenance
rule (same discipline as docs/FIDELITY-CHECKLIST.md): a sandbox round or corpus addition that
refutes a convention updates this file.
Pick the archetype before calling any tool:
| Archetype | Fits | Skeleton |
|---|---|---|
| Trading document | Quote, order, invoice, credit memo, shipment — one document per record, addressed to a counterparty | Title/logo chrome → address block → document-info grid → line-items table → totals (§2) |
| List / analysis report | Commission, register, aging, activity lists — rows grouped under entities, running chrome | Header/footer parts with report chrome → grouped repeater table with nested detail rows → totals (§3) |
| Per-entity statement | One sub-document per customer/vendor with a page break between them | Author ONE entity's body bound under the top-level item (e.g. /Customer/...), then wrap_in_repeater with wholeBody=true, pageBreakBefore=true: the stock shape [stock: 1316], w:group included. BC already prints the body once per top-level record without it; the wrap gives every record its own page in one document. BC prints the tool-written shape as intended: each customer on its own page with its own data, no blank first page [verified: P12]. |
Settle before building (ask only what the request leaves open): which parties' addresses (two is
the default; add ship-to when it differs [stock: 1322 buy-from + ship-to + company]), which
document-info fields, which line columns and their order, and whether a branded templatePath
shell exists or the build is blank.
Then obtain the schema artifact (al-word-layout §1 — transplanted, never synthesized), run
create_layout, and call list_dataset_fields before designing anything: design against what
the dataset actually offers. Bind label columns wherever they exist; when a report has none (old
Labels-data-item style), headerFromLabels=true falls back to humanized static headers —
BC-verified acceptable [verified: P07]. A blank build's body already carries a bold heading
paragraph with the report name; pass create_layout's headingText to override it (the verified
builds pass the all-caps document name, e.g. "STANDARD PURCHASE ORDER").
Build top-to-bottom; every block is appended with locationType=documentEnd, then filled through
the table index the insert response returns. The whole recipe below rendered correctly in BC.
| # | Block | Calls | Verified shape |
|---|---|---|---|
| 1 | Title | (from create_layout headingText) | All-caps report/document name, bold heading paragraph |
| 2 | Logo | insert_picture | /…/CompanyPicture, 35×18 mm. A Word save squares it to 18×18, so if the layout will be edited in Word, do that first |
| 3 | Address block | insert_table rowCount=6, columns=[{"width": 4600}, {"width": 4600}], then 12× insert_field (tableCell) | Borderless; company addresses down col 0, counterparty (customer/vendor) down col 1, one bound field per cell, filled row-major |
| 4 | Info grid | insert_table rowCount=3, columns=[{"width": 2800}, {"width": 3000}], then per row insert_label col 0 + insert_field col 1 | Caption beside value — see §4 for the caption-above stock alternative |
| 5 | Section heading (optional) | insert_text | format={"bold": true, "fontSizePoints": 16} heading (e.g. "ORDER LINES"), plus a default-size note line [verified: P06] |
| 6 | Line items | insert_repeater_table, headerFromLabels=true, columns with a width and alignment per column | Numeric columns right, text left, description widest (give it no width and it takes what the others leave); tableStyle="TableGrid" for a full grid or no style + a header rule for the open look (§4) |
| 7 | Totals | Stock shape: insert_table_row on the line table (a spacer row such as cells=[{"span": 8}], then the bound bold row), set_cell_format for the rule — see §4. Simpler BC-verified alternative: insert_table rowCount=1, columns=[{"width": 6200, "alignment": "right"}, {"width": 2400, "alignment": "right"}], 2 fills, set_cell_format | Totals text/label left, bold amount right, ½ pt rule on top (edges=["top"], borderSize=4) |
Checkpoint rhythm: the verified builds ran one validate_layout level=full + one preview_layout
at the very end and passed 0/0 — sufficient at this scale, though per-block preview_layout +
render_preview_pages is cheap whenever unsure.
insert_label (report-name label) with layoutPart="header", then any static
text via insert_text locationType="afterControl" anchored to that label's controlId —
control first; plain runs return no id and can never be the anchor.insert_repeater_table over the top-level data item; humanized static headers
are fine when no label columns exist.insert_repeater_row on the parent repeater's controlId; start
cells with an empty cell ({}) so the first column stays an empty indent spacer and the
detail data sits under parent columns 2+; right-align amount cells with their alignment.
Holds the parent grid without drift across pages in BC [verified: P07].insert_label when it lives in a
Labels data item [verified: P07].Stock contrast [stock: 115, 1016]: Microsoft's list reports are ONE table with group-header rows
and per-group subtotal rows inside the repeat, and put the chrome (title, date, page, user,
printed filter expressions) in the running header part. That grouped shape is buildable
[stock: 115 — its exact item structure]: the repeater's own line row IS the group header
(salesperson code/name — insert_repeater_table), the nested detail rows are
insert_repeater_row, and the trailing per-group rows are insert_subtotal_row — first an
all-spacer row (cells=[{"span": 9}] on a 9-column grid), then the bold subtotal row binding the
dataset's per-group totals (in 115, a sibling non-repeating Subtotals item), amounts
right-aligned. Grand totals close the table as a static insert_table_row (or the separate
totals table, which is the BC-verified simpler shape [verified: P07]). BC prints the tool-built
grouped shape as intended: the subtotal pair once per salesperson after their entries, the grand
total once at the end, and the subtotals sum to it [verified: P16]. Bind group totals from the
Subtotals item only: 115's group row carries SalesCommissionAmt/AdjProfitCommissionAmt too, but
they hold the FIRST entry's values, which is why the stock group row shows only code, name and
commission % [verified: P07, P16].
4600,4600 is the verified default. Stock varies by requirement: 2-col
customer|company [1304], 4-col buy-from|spacer|ship-to|company [1322], stacked single-column
blocks [1316] — party count follows the document, not a rule.BuyFromAddr1–8, as the stock order does [stock: 1322];
VendAddr1–8 print empty on an order [verified: P06]. The mock cannot show that, because generated
data fills every field (§6).insert_label, not insert_text.2800,3000): the verified
recipe [P01, P06] and the Statement's stock shape [1316].insert_table (rowCount rows, one columns entry per column), insert_label into the caption
row's cells, insert_field below.
Stock captions are smaller + bold (9 pt bold over 11 pt values).headerFromLabels=true); humanized
static text otherwise [verified: P07].insert_repeater_table always marks it w:tblHeader, a corpus-observed shape [stock: 1304,
115]. BC honours it [verified: P07], and since the #19 fix the mock preview repeats it too.insert_repeater_table draws by default (borders="headerRule"); add nothing. (A plain
insert_table takes the same borders="headerRule"; on an existing table the rule is
set_cell_format row=0, edges=["bottom"], borderSize=4.)tableStyle="TableGrid" — the style reference alone draws the
½ pt grid (BC honours w:tblStyle against the scaffolded styles part); don't also paint
per-cell borders. (borders="grid" paints the same grid as explicit table borders instead, and
BC prints that too [verified: P14].)set_cell_format edges=["bottom"] on the
repeater's data (template) row, which repeats per line [verified: P14]; its solid colour header
band is set_cell_format's fill on the header row [verified: P13].borderSize=4) is the only rule weight observed anywhere in the corpus — use it unless asked.insert_table_row on the line table (omit atRow to append), cells laid on the same
grid — a leading spacer cell, a spanned caption cell bound to the totals TEXT field, the
amount cell right-aligned, format={"bold": true}; then set_cell_format on the new row for the rule.
Example on an 8-column stock lines table:
cells=[{"span": 4}, {"fields": ["/Header/Totals/TotalIncludingVATText"], "span": 3}, {"fields": ["/Header/Totals/TotalAmountIncludingVAT"], "alignment": "right"}].
A spacer row before it (cells=[{"span": 8}]) is the stock spacing. BC prints the rows once, after
the last line [verified: P15].insert_table_row
calls: amounts share the right column, the grand-total row gets the bold + rule treatment.columns=[{"width": 6200, "alignment": "right"}, {"width": 2400, "alignment": "right"}], totals TEXT field (or label) in
col 0, amount field with format={"bold": true} in col 1, then set_cell_format edges=["top"], borderSize=4 on
row 0.w:titlePg set. Header/footer bindings are verified
[P07, plus a stock-layout header/footer probe in the same sandbox rounds] — but remember the
first-vs-default part trap (issue #5): with titlePg, page 1 renders the FIRST-page part, so
an edit landing in the default part is invisible on page 1.Page_Lbl + two literal spaces + Word PAGE/NUMPAGES field codes
[stock: 1304, 1322, 1306, 115 — identical construct in all four]. Buildable: insert_label the
Page_Lbl, then insert_page_number (afterControl on the label), then insert_text " "
(afterControl on the label again) — it emits the exact stock field construct (X / Y by default;
includeTotal=false for the bare page number). BC counts it correctly [verified: P15].locationType="afterControl" anchored on that first control — every such insert lands directly
after the anchor, so for Label: Value insert the label, then the value, then the ": " text.
documentEnd appends a NEW paragraph per call. Separators are literal runs (" ", " | ",
", ") [stock: every multi-control line; verified: P07].Normal/TableGrid styles, BC-verified to render
identically in Word and BC [verified: all three]. Don't fight it — layer format (bold, size)
where needed (a 16 pt bold section heading over the pinned base is verified [P06]).Strong or Segoe UI 8 pt neighbours.
Pass format only to differ from them.format (Job Quote's are Segoe UI 8 pt; a bare row printed at 11 pt [verified: P04]).validate_layout warns (font-installed).format also takes italic, underline, a font (Segoe UI is what Microsoft's own layouts set on
nearly every run [stock]), a colour (0070C0 is the stock accent blue [stock]) and a character
style the layout defines (Strong in the stock document layouts [stock]).set_text_format: a stock control by id, a header row in one
call (target="row"), or one exact piece of text.set_text_format (or
set_cell_text) with paragraphStyle "Heading1", plus clearDirectFormatting so the style is not
hidden under a direct font and size. Microsoft's themable layouts style the title and company name
Heading1/Heading2 this way [stock: StandardSalesInvoiceBlueSimpleThemable]. It needs a BC 29 target
and a style the layout defines (a blank create_layout build's only paragraph style is Normal, so
headings need a templatePath that defines them).set_cell_format's fill: the stock fills are a light grey E8E8E8 and the
accent blue 0070C0 [stock]. Most stock tables carry no fill at all, so use it sparingly.accent1, text2 lighter 40%,
background2 darker 25%, as Word's palette names them. The text, fill or rule then follows the
layout's own theme part. Microsoft's themable layouts colour every accent through accent1 this way
[stock: the three themable captures]. Prefer a slot when the layout should take a theme's colour,
and a hex value when the colour is fixed by the brand. A slot needs a layout with a theme part (a
blank create_layout build has none) and a BC 29 target. A report theme selected in BC replaces
the layout's own theme at print time, so every slot, tint and theme font follows it; literal colours
and named fonts stay [verified: BC 29, Calm and Playful]. Without one, BC prints the layout's own
theme colour.templatePath shell or hand-edit the OOXML and re-validate (al-word-layout §3). When the look
already exists as a finished Word design with sample values, follow al-word-layout-from-design
instead of rebuilding it here; for a theme shared across reports, al-word-layout-composite.insert_table's default even
split fills the layout's own content width (page width minus margins), and falls back to 10206
when the layout declares neither.w:tblLayout="fixed"
plus a w:tblW total equal to the grid's sum [stock: all 4 tables in 1322], so Word renders the
grid as specified. Before that they were autofit, i.e. advisory — Word recomputed them from
content, which is why a line table could read as near-uniform in Word while the mock preview
looked right (#52). Proportion choices
are therefore worth making deliberately; nothing downstream will "fix" a bad split.| Stock idiom | Why no tool | Route |
|---|---|---|
Page-position-conditional BOUND content (a field inside IF PAGE = NUMPAGES) | Static text is buildable: insert_page_conditional_text (lastPage, notLastPage, firstPage), which BC evaluates per page [verified: P11, on a two-page and a one-page order]. A bound control inside the IF result is untested in Word and BC (#11) | Put the static caption on the last page with the tool and leave the bound value unconditional, or hand-edit + validate_layout |
| Hide-if-empty add-in controls | No tool writes them (#123). Row/table variants captured [stock: 115, SubcontractorDispatchList]. Outside a repeater neither hides anything, for a missing first child record [verified: P09, P10] or an empty value [verified: P19]. Inside a repeater the row variant hides the WHOLE repeated item (the line and every row in it) when its cell is a missing record or an empty value, and keeps it when filled [verified: P20, P21, P22]. The table variant around one cell does nothing, inside a repeater or outside [verified: P23, P24, P10]; around a whole table it is untested. Hide Field if Zero never captured (#8) | To drop repeated items whose value is empty: hand-wrap a cell of the item in the captured shape (a cell-level control in the wrapper), then validate_layout; otherwise reserve the rows/cells, as stock layouts do |
One known mock-preview gap hides a design mistake: generated data fills every field, so a field
that is empty in real data looks filled in the mock. A purchase order's VendAddr block previewed
full and printed empty [verified: P06]. When it matters which of two similar fields carries the data,
preview with a real dataset export (dataOverridesPath). The gap that used to mislead layout work —
a repeated table header row never spanning pages in the mock even when BC repeats it — is fixed
(#19). Sandbox render stays the sign-off (al-word-layout §4); a newly discovered gap gets listed here
so nobody redesigns around a mock artefact.
list_dataset_fields isLabel), not
static text; static headers only where no label column exists.validate_layout level=full passes 0/0 and the preview pages were actually looked at
(render_preview_pages), modulo any §6 caveats.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tkapitan/bc-word-layout-mcp --plugin bc-word-layout4 skills in this plugin
/al-word-layoutUse whenever inspecting, creating, editing, validating, or previewing a Business Central Word report layout (.docx) — BC Word layouts, report layouts, and their bound content controls (fields, labels, repeater tables) — through the bc-word-layout MCP tools, instead of hand-editing the underlying OOXML directly. Covers the inspect → edit → validate → preview workflow, the exact tool surface and parameters, what the tools do and do not support, and the error envelope every tool returns./al-word-layout-compositeUse when building, splitting or debugging a Business Central composable (composite) Word layout - a report BODY, a reusable HEADER/FOOTER layout and a report THEME (.dotx) that BC combines at print time. Covers what each of the three files must and must not contain, the style contract between theme and body, splitting one designed document into the three parts, the checks to run, and why a theme can fail to restyle a body. Complements al-word-layout (tool mechanics) and al-word-layout-from-design (binding a finished design)./al-word-layout-from-designUse when someone already has a finished Word DESIGN of a Business Central document (a styled .docx with sample values typed in — logo box, colours, an invoice/quote/order mock-up) plus the report's empty BC layout, and wants a working, data-bound BC Word layout that keeps that design. Written for a functional consultant who does not code - the agent does all file work. Covers what to ask for, mapping sample text to dataset fields (and confirming it), building the bound layout, checking it, and the handover. Complements al-word-layout (tool mechanics) and al-word-layout-design (from-scratch conventions).Other plugins' skills for the same job