Advanced Spreadsheets and Reporting Documentation
Index

Journal and Document Regions

Three region types put one journal batch or one document's lines on the sheet as an editable grid: G/L Journal, Sales Document and Purchase Document. They behave like an editable table region with three things decided for you:

  • The table is implied by the type: Gen. Journal Line, Sales Line or Purchase Line.
  • The filter is built from the region's keys on every fill: the journal template and batch, or the document type and number. The keys accept [Address], so a slicer can pick the batch or the document.
  • The columns default to the fields the standard Business Central page shows, in page order — read from the page's controls, so a column you see on the General Journal or on the Sales Order lines is a column here.

On top of that, the region can add lines: a blank row under the last line inserts a new line when you type a value into it.

For sales and purchase documents the region holds the lines only. The header stays on the document card.

Opening from the standard pages

Every general-journal page (General Journal, Sales Journal, Purchase Journal, Cash Receipt Journal, Payment Journal) has an Open as Spreadsheet action. It opens a new, unsaved sheet with a title and a G/L Journal region for the batch the page has open, with the page's own columns.

Every sales and purchase document card (quote, order, invoice, credit memo, blanket order, return order) has an Open Lines as Spreadsheet action doing the same for the document's lines, with the columns of the document type's lines subform.

Save the sheet like any other to keep it; the region keeps pointing at that batch or document.

The region badge

The badge names the source, not just the region: Sales Order 101005 — Adatum Corporation, Purchase Invoice 107001 — Fabrikam, Inc., Journal GENERAL DEFAULT — Default Journal Batch. The sell-to customer name, buy-from vendor name or batch description is read from the header when it exists. The keys are resolved on every fill, so a region whose document number comes from a slicer shows the document — and customer — currently picked; a key that resolves to nothing shows ?. A description set on the region follows after that.

Setup

Field Meaning
Range Where the region starts, for example A3. Only the top-left cell is used — the width comes from the columns, the height from the lines (plus the new-line row).
Color The colour of the region's badge, tint and header shades.
Journal Template Name, Journal Batch Name G/L Journal only. The batch whose lines fill the region. The batch field has a lookup. Both accept [Address], for example a ?FIELD(Gen. Journal Batch, Name) slicer.
Document Type, Document No. Sales / Purchase Document only. The document whose lines fill the region. The number field has a lookup filtered to the type. Document No. accepts [Address], for example a ?FIELD(Sales Header, No.) slicer.
Columns from Page The page whose fields become the columns. Blank means the standard page: the journal template's page (General Journal, Payment Journal, …) or the document type's lines subform (Sales Order Subform, Purch. Invoice Subform, …). The lookup offers only pages showing the line table.
Columns How many columns the region has and where they came from. The AssistEdit button reloads them from the page — useful after changing the page, or when an extension added fields to it. Virtual columns are kept.
Allow Table Editing Default on. Edits are validated and written back to the lines. Off makes the region read-only and hides the new-line row.
Allow Adding Lines Default on. Shows the blank row under the last line that inserts a line.
Max Rows, Include Headers As for table regions.

The columns are ordinary region fields: reorder them, drop the ones you do not need, set a caption or a number format, add virtual columns with formulas — a per-line margin next to the unit price, say.

Which fields become columns

The region reads the page's control fields — every control bound to a field of the line table — and keeps the ones that could show: hidden controls (Visible = false), FlowFilters, removed fields and primary-key members (Line No., Document No.) are left out, and a field shown twice appears once. Fields the page shows only under Show more are included; remove the ones you do not want.

A column is editable only when the page plainly lets you edit the control: its Editable and Enabled properties are blank or true. A control the page decides at run time (Editable = IsOpen, Enabled = false) becomes a column flagged Read Only in the region's fields — the sheet cannot evaluate the page's condition, so it errs on the safe side. Clear the flag in the region's fields if you know better; set it on any column you want to protect.

Editing lines

A cell of an existing line behaves exactly as in a table region with editing on: type a value and it is validated into the field, running the same code the page would — account lookups, price calculation, dimension checks, status checks. A failing validation shows in the status bar and the cell keeps the stored value. Read-only fields (calculated fields, disabled fields, keys) are muted.

A formula in a line cell writes its result back on every recalculation, as on table regions — and because a written quantity or price changes the line's other fields (line amount, VAT, the document total), the sheet re-reads the lines and evaluates once more in the same recalculation, so the whole row refreshes and formulas reading those fields see the new values. A quantity on line 1 that is a formula over line 2's quantity therefore updates line 1's amount the moment line 2 changes.

Cells of lines belonging to a released document, or to a batch you may not post, fail their validation the way the page would refuse them.

Adding lines

The last row of the region is blank, marked with a dashed top edge and a + in its first column. Type a value into any editable cell of that row and the region:

  1. Creates a new line at the end of the batch or document, with the keys of the region and the defaults the standard page gives a new line — for a journal that is SetUpNewLine: posting date, document number (incremented when the journal balances), account type, balancing account from the batch; for a document line the previous line's type, or the setup's default line type on an empty document.
  2. Validates the typed value into the field you typed in.
  3. Inserts the line. On the next fill the line renders as a normal editable row, and a fresh blank row appears under it.

So the natural way to add a journal line is: type the account number in the Account No. cell of the blank row, then fill Amount and the rest in the new row. Typing several values into the blank row at once (a paste) inserts one line per edit — paste into existing rows instead, or add the lines one by one.

A formula typed into the blank row does not insert a line; it is stored as an ordinary sheet cell.

The new-line row only shows where a line could actually be inserted: the region allows editing and adding lines, the sheet is open by its owner in edit mode, the region reads the company you work in, and your permission set allows writing (see Permissions). It never shows on a page other than the last one.

Using the region in formulas

Like a table region, the region's ID is a record variable formulas can use: =JOURNAL.Count, =LINES.TableSum("Line Amount"). The record is positioned on the region's filtered set — the batch or the document.

Notes

  • Company: the region reads the company you work in. Reading another company is possible through the Company setting, but such a region is read-only and has no new-line row — field validation would run against the wrong company's setup.
  • Caching: none — the region renders live on every recalculation, like table regions.
  • Excel export: the region exports as an Excel table, like a table region. The blank new-line row is not exported.
  • Templates and export/import: the region's keys, page and options travel with the sheet like every other region setting.