Word Templates and Custom Layouts
The SharePoint Connector supports Word templates and custom report layouts for document generation. This page explains how to work with Word-based templates.
Word Templates Overview
What Are Word Templates?
Word templates in Business Central:
- Define document appearance
- Use Word's formatting capabilities
- Include placeholders for BC data
- Can include images, tables, headers
How They Work with the Connector
- Create Word template layout in BC
- Reference layout in Document Template
- Generate document → uses Word layout
- Output as Word (.docx) or PDF
Which Layout System Applies
The Report Layout Selection field on the SharePoint Setup page governs which of BC's two layout systems the connector uses:
| Report Layout Selection | Layout System | Template List | Layout Field Contains |
|---|---|---|---|
| Report Layout (default) | Modern Report Layouts (Report Layout List) | SharePoint Document Templates (Report Layout) | The layout name from the Report Layout List |
| Custom Report Layout | Legacy Custom Report Layouts | SharePoint Document Templates (Custom Report Layouts) | The layout code (e.g., MY-CUSTOM-LAYOUT) |
The shipped default is Report Layout. With that default, the Layout field on the template holds the layout name, and the connector applies it via design-time report layout selection for the generation run only. Layout codes such as MY-CUSTOM-LAYOUT apply only when Report Layout Selection is set to Custom Report Layout.
The Word template design process (content controls, XML mapping) is the same for both flavors.
Creating Word Layouts
Step 1: Design the Template
In Microsoft Word:
- Create a new document
- Design your layout (headers, formatting, logo)
- Leave space for BC data
- Save as .docx
Step 2: Add Content Controls
Use Word's XML Mapping Pane:
- In Word, go to Developer tab
- Click XML Mapping Pane
- Add content controls where data should appear
- Map controls to BC data fields
Step 3: Import to Business Central
For the default Report Layout flavor:
- Go to Report Layouts (the Report Layout List) in BC
- Create a new layout for your report and choose Word format
- Import the Word template
- Note the layout Name -- you reference it in the document template
If Report Layout Selection is Custom Report Layout:
- Go to Custom Report Layouts in BC
- Create new layout for your report
- Import the Word template
- Note the layout Code -- you reference it in the document template
XML Mapping Process
Accessing XML Mapping
In Word 2016 or later:
- File > Options > Customize Ribbon
- Enable Developer tab
- Go to Developer > XML Mapping Pane
Mapping BC Data
The XML mapping pane shows available data:
- Select the data source (BC report dataset)
- Find the field you want
- Insert a content control
- Map the control to the field
Common Mappings
| Content Control | BC Field |
|---|---|
| Company Name | COMPANYNAME |
| Customer Name | Cust_Name |
| Document No. | Doc_No |
| Total Amount | TotalAmount |
Using Word Layouts with Templates
In Document Template Configuration
With the default Report Layout flavor, the Layout field holds the layout name:
| Field | Value |
|---|---|
| Table No. | 18 (Customer) |
| Report Number | 116 (Statement) |
| Custom Layout | Statement - Word Layout |
| Output Type | Word or PDF |
With Report Layout Selection = Custom Report Layout, the Layout field holds the layout code instead (e.g., MY-CUSTOM-LAYOUT).
Layout Lookup
For the default Report Layout flavor, the Layout field accepts:
- A layout name from the Report Layout List
- Applied via design-time report layout selection, for the generation run only
For the Custom Report Layout flavor, the Layout field accepts:
- A custom layout code
- Must exist in Custom Report Layouts
- Must be for the specified report
Output Format Options
Word Output
When Output = Word:
- File saved as .docx
- Fully editable in Word
- Good for documents needing modification
PDF Output (from Word Layout)
When Output = PDF (with Word layout):
- Word layout is used for formatting
- Output is converted to PDF
- Professional, non-editable result
Template Design Best Practices
Layout Tips
| Element | Recommendation |
|---|---|
| Logo | Include company logo |
| Header | Company info, document title |
| Footer | Page numbers, dates |
| Fonts | Use standard fonts |
| Tables | For line items |
Data Placement
| Area | Typical Content |
|---|---|
| Top | Company logo, return address |
| Address block | Customer/vendor address |
| Body | Document-specific content |
| Summary | Totals, signatures |
Testing
Before production use:
- Generate test document
- Review all fields populate
- Check formatting
- Test in target application (Word, PDF reader)
Example: Customer Letter Template
Word Template Design
[Company Logo]
[Company Name]
[Company Address]
[Date]
[Customer Name]
[Customer Address]
Dear [Contact Name],
[Letter Body - Content Control for variable text]
Thank you for your business.
Sincerely,
[Salesperson Name]
BC Configuration
| Field | Value |
|---|---|
| Table No. | 18 |
| Report Number | (Custom letter report) |
| Layout | Customer Letter V1 (layout name; use a layout code like CUST-LETTER-V1 only with the Custom Report Layout flavor) |
| Description | Customer Letter %1 |
| Output | Word |
Troubleshooting Word Templates
Layout Not Found
| Check | Resolution |
|---|---|
| Layout exists? | Create in Report Layouts (or in Custom Report Layouts for the legacy flavor) |
| Correct name/code? | Report Layout flavor uses the layout name; Custom Report Layout flavor uses the layout code |
| For correct report? | Layout must match Report No. |
| Right flavor? | Check Report Layout Selection on the SharePoint Setup page |
Data Not Appearing
| Issue | Check |
|---|---|
| Empty fields | Verify XML mapping |
| Wrong data | Check mapping to correct fields |
| Missing fields | Field may not be in dataset |
Formatting Issues
| Issue | Resolution |
|---|---|
| Fonts wrong | Use standard fonts |
| Layout shifted | Check table/paragraph settings |
| Images missing | Embed images, don't link |
Advanced Word Features
Conditional Content
Word layouts can include:
- Conditional sections (show/hide based on data)
- Repeating sections (for line items)
- Dynamic tables
Repeating Sections
For tables with multiple rows:
- Create a table in Word
- Add repeating section content control
- Map to repeating data in BC dataset
Images
Include images:
- Company logo (static)
- Product images (dynamic, if in BC)
- Signatures