Business
Central 29.0 lets you stop baking branding into every Word layout. Instead of
one file carrying structure, letterhead and typography all at once, you build
three separate pieces and Business Central merges them when the report runs.
This
walkthrough takes one report from plain to fully branded, then sets it as the
default so you never repeat the work.
The nine steps: build the header/footer in Word →
register it → approve it → create the theme → get a Body layout → assign both
parts → run it → set defaults → do the same in AL.
Before you start: a 29.0 environment, Word on your
machine, and the Cronus logo file.
What we are building
We will
brand the Standard Sales - Invoice
report for a company called Contoso. By the end you will have:
• A header/footer part carrying the
Contoso letterhead and a footer with the company registration line
• A theme part carrying the Contoso
fonts and colors
• A body layout holding only the
invoice structure
• Both parts assigned, first to one
layout, then as a company-wide default
what you
build · 3 parts, merged at render
Two pages do
all the work. Report Layouts holds
layouts with subtype Default and Body. Manage themes and header-footer layouts holds the ones with subtype
HeaderFooter and Theme. A layout appears on exactly one of
them, decided by its subtype.
Step 1. Build the header
and footer in Word
Start with a
blank Word document. This file will carry nothing but page furniture, so do not
add any invoice content to it.
Go to Insert > Header, pick a style, and drop in the Cronus logo. Then Insert > Footer for the address.
Save it as Contoso-External-HF.docx. Plain .docx, not a template.
Step 2. Register the
header/footer part in Business Central
Press Alt+Q, type Manage themes and header-footer layouts, and open the page. This page is
empty of your own parts on a fresh environment, though Microsoft's shipped
designs are already listed.
Choose New header/footer. Enter a Name and Description, then OK.
Select the Contoso-External-HF.docx file you saved. The part is now
registered.
Step 3. Approve the part
before you try to use it
This is the
step that catches everyone. A freshly created part cannot be assigned to
anything yet. Try it and you get:
The part
Contoso external letterhead is not approved. Only approved themes and
header/footer parts can be assigned. Approve it in Report themes and
header-footer setup first.
Open Report themes and header-footer setup
and click action Set as approved. Then go back.
It is worth
understanding why this gate exists rather than clicking through it. These parts
are shared. One of them can end up on every outgoing document in the company,
so the approval step is what stops a half-finished letterhead from reaching a
customer. In a real rollout, treat approval as the point where someone who owns
the brand signs off, not as a checkbox the developer ticks.
Step 4. Create the theme
part
Same page,
different action: New theme.
The
important difference is the file type. A theme has to be a Word template, a .dotx file, not a .docx. That is the t in dotx doing its job. A theme carries fonts
and a color palette rather than content, which is exactly what a Word template
is for. Try to upload a .docx here and it will not take.
So in Word:
set up your fonts and colors on the Design tab, then Save As and pick Word
Template (*.dotx). Name it Contoso-Brand.dotx and register it as a new theme.
Approve it, same as step 3.
If you want
to see what good looks like before building your own, open one of the shipped
themes first. Microsoft ships three: Calm, Playful, and Standard, alongside the
Default. Calm is muted and green, Playful adds color and gradients. Export one,
look at how it is put together, then build yours from that starting point
rather than from blank.
Step 5. Get yourself a Body
layout
Here is the
part that trips people up on day one, so read it before you start clicking.
A theme and
a header/footer can only be assigned to a layout whose subtype is Body. Not Default. The difference matters because a Default layout is a complete document that already owns its own
header, footer and styling, so there is nothing for the merge to add. A Body layout is deliberately incomplete and expects the other two
parts to be merged in at render time.
On the Report Layouts page you will see the
new Subtype column. Filter it and
check what you actually have. Two things you will hit:
• Select an RDLC layout and the
composite actions are greyed out. This feature is Word only.
• Select a Default layout and you get an error telling
you the layout cannot carry a theme or header/footer.
If the
report you want has no Body layout, the quickest route is to
export the existing standard layout, then import it back as a new layout with
the subtype set to Body. Open it in Word first and strip out
the header, the footer and the hard-coded styling, because those are now the
job of your two parts. What should be left is the invoice structure and nothing
else.
Run it at
this point, before assigning anything. You should get a very plain document
with no letterhead and no branding. That is correct, and it is a useful
checkpoint: if it still looks branded, you have not stripped the layout
properly and you will get a doubled-up header later.
Step 6. Assign the theme
and header/footer
Select your
body layout on Report Layouts, open
the Composite Layout menu, and
choose Set report theme and
header-footer.
Pick Contoso external letterhead as the header/footer part and Contoso Brand as the theme part. If either one is missing from the
dropdown, it is not approved yet. Go back to step 3.
Step 7. Run it
Run the
Sales Invoice and pick your body layout. The PDF now comes out with the Contoso
letterhead on page one, the registration footer on every page, and your fonts
and colors throughout. The body layout file itself has not changed since step
5. The merge happened at render time.
Step 8. Set defaults so you
stop doing step 6
Assigning
parts layout by layout works, but it does not scale past a handful. The
defaults page is where this becomes genuinely useful.
Open Report defaults for themes and
header-footer setup. You can set a default theme and header/footer at four
levels, and the most specific one wins.
defaults
cascade · 4 levels, most specific wins
Worked
through with our example:
1. Global. Set
Contoso Brand and the external letterhead here. Every document report in every
company now uses them.
2. Company.
Contoso Denmark needs a different registration footer. Add a company-level row
for it, pointing at a Danish header/footer part. Denmark overrides global;
everything else still follows global.
3. Report. Credit
memos need a plainer treatment than invoices. Set a report-level row on the
credit memo report.
4. Layout. One
specific body layout needs something unusual. Set it there, exactly as you did
in step 6.
The
multi-company case is where this earns its keep. Set Danish branding once on
the Danish company and every document report in that company follows, with no
per-report work at all. Add a Swedish company next year and it is one row, not
a layout migration.
Step 9. The same thing in
AL
Everything
above has a code equivalent. Three properties do it, all documented in the AL
Language extension changelog: Subtype on the layout, plus HeaderFooterPart and ThemePart on a body layout.
report 50100 "Contoso Sales Invoice"
{
Caption = 'Contoso Sales Invoice';
DefaultRenderingLayout = ContosoInvoiceBody;
dataset
{
// data items here
}
rendering
{
layout(ContosoInvoiceBody)
{
Type = Word;
Subtype = Body;
LayoutFile = './Layouts/ContosoInvoice-Body.docx';
Caption = 'Contoso sales invoice';
Summary = 'Invoice structure only. Theme and header/footer merge at render time.';
HeaderFooterPart = ContosoExternalHF;
ThemePart = ContosoBrandTheme;
}
layout(ContosoExternalHF)
{
Type = Word;
Subtype = HeaderFooter;
LayoutFile = './Layouts/Contoso-External-HF.docx';
Caption = 'Contoso external letterhead';
Summary = 'Logo, address block, registration footer.';
}
layout(ContosoBrandTheme)
{
Type = Word;
Subtype = Theme;
LayoutFile = './Layouts/Contoso-Brand.dotx';
Caption = 'Contoso brand theme';
Summary = 'Corporate fonts and color palette.';
}
}
}
Note the
file extensions in LayoutFile, because the compiler will hold you
to them. Theme points at .dotx. Body and HeaderFooter point at .docx.
If you are
building a branding extension rather than a report, you can ship nothing but
parts. A report extension that adds only Theme and HeaderFooter layouts puts them into the shared
pool for administrators to assign from the setup page:
reportextension 50101 ContosoBrandParts extends "Standard Sales - Invoice"
{
rendering
{
layout(ContosoInternalHF)
{
Type = Word;
Subtype = HeaderFooter;
LayoutFile = './Layouts/Contoso-Internal-HF.docx';
Caption = 'Contoso internal header/footer';
Summary = 'Single rule line. For internal print and PDF.';
}
layout(ContosoCalmTheme)
{
Type = Word;
Subtype = Theme;
LayoutFile = './Layouts/Contoso-Calm.dotx';
Caption = 'Contoso calm theme';
}
}
}
One 29.0
change makes reusable header/footer parts work far better than they otherwise
would: Word layouts now include a company information dataitem shared across
every report dataset. A shared letterhead needs the company address and
registration number, and it can no longer assume each report declared them.
That dataitem is why a single header/footer part can sit on fifty different
reports and still print the right company details.
So the
migration looks like this: build the body layout and parts alongside the old
layout, assign and test, then retire the old layout rather than deleting it. If
something is wrong, flip the status back. Nobody loses a document in the
meantime.
No comments:
Post a Comment