In the first post, we connected the agent and inspected an existing layout. This time, let’s create a small quote: a heading, the document date, and a repeating line table.
It is an exercise, not a complete customer document. Addresses, VAT details, payment information, and other business requirements still need to be added before using it.
Updated 25 October 2026: This walkthrough now uses released v2.0.0. The task is unchanged, but the table example and preview options have been updated from the original v1.0.0 API.
Prepare the source
Use the setup from part 1. In BC, export a Word layout for the sales quote report you want to use and save it as C:\BCLayoutDemo\Quote.schema.docx.
That file tells the agent which fields the report provides. It is the schema source, not necessarily the design of the new document.
For a custom AL report, build the project first and use the generated layout. If you do not have access to BC for the exercise, the repository contains a captured standard sales quote layout you can download as the source instead.
A report’s Send to > XML export is different: it supplies values from a report run for previewing. It does not replace the layout’s schema.
Agree on the fields before building
Start with this prompt:
Use BC Word Layout MCP to inspect C:\BCLayoutDemo\Quote.schema.docx.
Find the document date, its caption, and the repeating sales lines.
For the lines, find item number, description, quantity, and line amount.
Show me the matching dataset fields. Do not create a document yet.
For the captured quote, you should find /Header/DocumentDate and /Header/Line, with the line columns beneath that item. Your own report can use different names.
Confirm the mapping, especially the amounts. A unit price, a line amount, and an amount including VAT are not interchangeable.
Give the agent a small layout brief
Create C:\BCLayoutDemo\Quote.docx using Quote.schema.docx as the source.
Start with a blank design, not a copy of the standard layout's appearance.
Add a Sales Quote heading and the document date with its dataset caption.
Then add a repeating line table with item number, description,
quantity, and line amount, in that order.
Make the description the widest column and right-align the numeric columns.
Use dataset captions where available and a rule below the table header.
Do not change the source file or invent fields or totals.
The agent can use create_layout, insert_label, insert_field, and insert_repeater_table for this.
The important result is that each line is bound to the report’s repeating data item. A table filled with sample text is not a working report layout.
If you work with tool calls directly
In v2.0.0, each column is an object with a full dataset path. For the captured quote, these are valid arguments for insert_repeater_table:
{
"layoutPath": "C:\\BCLayoutDemo\\Quote.docx",
"dataItem": "/Header/Line",
"columns": [
{"field": "/Header/Line/ItemNo_Line", "width": 1400},
{"field": "/Header/Line/Description_Line"},
{"field": "/Header/Line/Quantity_Line", "width": 1200, "alignment": "right"},
{"field": "/Header/Line/LineAmount_Line", "width": 1600, "alignment": "right"}
],
"locationType": "documentEnd",
"headerFromLabels": true,
"borders": "headerRule"
}
This is an illustration of the call the agent makes, not another table to insert after it has completed the prompt. The description takes the available width left by the other columns.
Older comma-separated column lists are not accepted by v2.0.0. Most users can leave these details to the agent and describe the required columns in the prompt.
Ask to see the result
Run full validation on C:\BCLayoutDemo\Quote.docx.
Create a preview with three sample rows.
Save the preview and page images under C:\BCLayoutDemo\preview.
Show me the pages and list any warnings or failed checks.
Do not report a PDF as ready if conversion failed.
Full validation checks the structure and whether the field bindings can be used. The local preview shows whether the layout is readable.
Check that:
- The document date has a caption, rather than an unexplained value.
- The lines repeat and the columns appear in the agreed order.
- Descriptions have enough space.
- Quantity and amount columns are easy to scan.
The agent uses preview_layout and render_preview_pages to produce and inspect the output. In v2.0.0, the preview row-count argument is sampleRows; page images can also be written to a folder you can open yourself.
Try a real quote
Generated sample data is useful for a quick check, but it is not your customer’s data.
Run the same report in BC and save its XML data export as C:\BCLayoutDemo\Quote.data.xml. Then ask:
Preview Quote.docx again using C:\BCLayoutDemo\Quote.data.xml
as dataOverridesPath. Use the exported values, not generated sample data.
Tell me if the dataset belongs to a different report.
For a document report, start with one quote. If the export contains several top-level documents, the local preview can show only the first and warns about that. It is not a batch-print test.
Finally, upload the layout for the correct report in a BC sandbox and print the quote there. Try a short quote and one with long descriptions and enough lines to span pages.
Keep the export and preview files under the same controls as other business data. The useful outcome is a small, working layout with a clear test result, not just a Word file that opens.