SharePoint Connector Documentation
Index

SharePoint Document Templates

Document templates allow you to generate reports from Business Central and automatically save them to SharePoint. This page explains how to configure and use document templates.

Two Template Flavors

The connector ships two parallel template lists, one bound to BC's legacy Custom Report Layouts and one bound to BC's modern Report Layout List. Both behave identically in terms of file naming, subfolder routing, categories, and the Generate Document action; the only difference is which layout system the report runs against.

Flavor Table List Page Layout Lookup When to Use
Custom Report Layout Document Template EFQ (70319503) SharePoint Document Templates (Custom Report Layouts) (70319505) Custom Report Layout records filtered by Report ID; field type Code[20] Reports whose layout was created in the BC Custom Report Layouts page
Report Layout Document Template RL EFQ (70319495) SharePoint Document Templates (Report Layout) (70319519) Report Layout List.Name; field type Text[250] Reports using modern BC Report Layouts (the unified layout list introduced in newer BC versions)

The Report Layout Selection field on the SharePoint Setup page (Setup group) decides which of the two lists the Generate Document action opens. The default after install is Report Layout. Switching the setting does not migrate data between the two tables -- each list maintains its own templates -- but only the active flavor is reachable from the FactBox.

Behind the scenes the connector calls GenerateDocument for the Custom Report Layout flavor and GenerateDocumentRL for the Report Layout flavor. Partner code that already calls GenerateDocument continues to work; new integrations targeting modern report layouts should use GenerateDocumentRL. See Programming Examples.

What Are Document Templates?

Document templates define:

  • Which report to generate
  • What format (PDF, Word, Excel)
  • How to name the output file
  • Where to save in SharePoint

Template Components

Template Configuration

Component Description
Table Which BC table triggers this template
Report The report to generate
Layout Optional custom report layout
Output Format PDF, Word, or Excel
File Naming How to name the output file
Subfolder Optional subfolder destination
Category Optional file category

Configuring Templates

Accessing Document Templates

Depending on the Report Layout Selection value on the SharePoint Setup page:

  • Search for SharePoint Document Templates (Custom Report Layouts) for the legacy flavor (page 70319505).
  • Search for SharePoint Document Templates (Report Layout) for the modern flavor (page 70319519).

Template Fields

The two flavors share the same field set, with one difference in the layout lookup:

Field Type Description
Table No. Integer BC table this template applies to
Report Number Integer The report to generate
Custom Layout (Custom Report Layout flavor) Code[20] Custom Report Layout code, filtered by Report ID. Lookup is Custom Report Layout.Code.
Custom Layout (Report Layout flavor) Text[250] Modern Report Layout name. Lookup is Report Layout List.Name.
Description Text[100] File name template (supports %1-%4 placeholders)
File Category Text[20] Category to assign. Lookup is SharePoint Category EFQ.Category filtered to the template's table.
Show Request Page Boolean Show report parameters before generating
Optional Subfolder Text[200] Subfolder for output (auto-created with parents if missing)
Output Type Option PDF, Word, or Excel

Creating a Template

  1. Open Document Templates
  2. Click New
  3. Select Table No. (e.g., 18 for Customer)
  4. Select Report No. (e.g., Customer Statement)
  5. Configure naming and options
  6. Save

Note: Validating Report No. resets the Description to the report's object name. Always set Report No. first, then customize the Description/file name.

File Naming

Placeholders

Use placeholders in the Description field:

Placeholder Replaced With
%1 Value from Folder Name Field (e.g., Name)
%2 Value from Folder Name Specification Field (e.g., No.)
%3 Current date/time in sortable format (e.g., 2024-01-15T14.30.45) with colons replaced by dots
%4 Current user ID (sanitized)

Example Naming

Description Result
Customer Statement Customer Statement.pdf
Customer Statement %1 Customer Statement Contoso Ltd.pdf
Customer Statement %1 (%2) Customer Statement Contoso Ltd (C00010).pdf
Customer Statement %3 Customer Statement 2024-01-15T14.30.45.pdf

Note: The underlying template tables also contain "Add Name to Document Name" and "Add Identification to Document Name" fields, but these are not currently available on either template page. Use the %1 and %2 placeholders in the Description instead.

Output Formats

Available Formats

Format Extension Best For
PDF .pdf Final documents, sharing
Word .docx Editable documents
Excel .xlsx Data exports, calculations

Choosing Format

Scenario Recommended Format
Invoices, statements PDF
Templates to fill in Word
Data analysis Excel
Contracts for editing Word

Using Templates

From the FactBox

  1. Open a record (e.g., Customer Card)
  2. In the SharePoint FactBox, click Generate Document
  3. Select from available templates
  4. Template runs and uploads to SharePoint

Template Selection

When multiple templates exist:

  • List of available templates shown
  • Select the one you want
  • Can generate different documents from same record

Request Page

If "Show Request Page" is enabled:

  • Report request page appears
  • Set parameters as needed
  • Click OK to generate
  • Useful for date ranges, filters

Template Examples

Customer Statement Template

Field Value
Table No. 18 (Customer)
Report No. 116 (Statement)
Description Customer Statement %1
Output PDF
Show Request Page Yes

Result: Customer Statement Contoso Ltd.pdf

Sales Invoice Template

Field Value
Table No. 112 (Sales Invoice Header)
Report No. 206 (Sales - Invoice)
Description Invoice %2
Output PDF
Optional SubFolder Invoices

Result: /Customers/Contoso/Invoices/Invoice 103001.pdf

Job Quote Template

Field Value
Table No. 167 (Job)
Report No. 1016 (Job Quote)
Description Quote for %1
Output Word
File Category Quote

Result: Quote for Project Alpha.docx with "Quote" category

Custom Report Layouts vs Modern Report Layouts

Using Custom Report Layouts (Legacy)

When Report Layout Selection is set to Custom Report Layout:

  1. Create the layout via the BC Custom Report Layouts page
  2. In the Custom Report Layout flavor template, pick the layout code from the lookup (filtered to the chosen Report)
  3. Generated documents use that layout
Field Value
Custom Layout CUST-INV-LAYOUT

Using Modern Report Layouts

When Report Layout Selection is set to Report Layout (the default):

  1. Create or import a layout via the BC Report Layouts (Report Layout List) page
  2. In the Report Layout flavor template, pick the layout by Name from the lookup
  3. The connector calls the report through the modern report layout selection codeunit, so the chosen layout is applied for the generation run only
Field Value
Custom Layout Invoice - Modern Layout

Leaving the layout blank in either flavor causes the report to run with its default layout.

Subfolders

Routing to Subfolders

Use Optional SubFolder to route output:

Field Value Result
Optional SubFolder Invoices Goes to /Invoices/
Optional SubFolder Generated Goes to /Generated/
Optional SubFolder (blank) Goes to main folder

Creating Subfolders

If the subfolder doesn't exist, it is always created automatically during generation -- including any missing parent folders in the path. No additional configuration is needed.

File Categories

Assigning Categories

Set File Category to auto-assign:

Field Value
File Category Invoice

Generated documents automatically have this category.

Category Benefits

  • Visual identification in FactBox
  • Email attachment automation
  • SharePoint filtering

Multiple Templates per Table

When to Use Multiple

Create multiple templates for:

  • Different document types
  • Different output formats
  • Different purposes

Example: Customer Templates

Template Purpose
Statement Monthly statement
Account Balance Quick balance report
Customer List Export for analysis

Best Practices

Template Design

Practice Benefit
Clear naming Easy to identify output
Use placeholders Dynamic file names
Assign categories Organization
Use subfolders Keep folders clean

Performance

Consideration Recommendation
Large reports Consider PDF
Complex layouts Test before production
Many records Use appropriate filters

Troubleshooting

Template Not Appearing

Check Resolution
Table mapping exists? Create mapping for the table
Template saved? Ensure template is saved
Correct table? Verify Table No.

Generation Fails

Error Resolution
Report error Check report works manually
Permission error Check SharePoint permissions
Path error Verify folder exists