ZuloOne
English
Sign inTry it
Menu

Report variants and reader settings

Updated

A report in Reports — a user report or a standard one shipped with a model — has variants: the same report with other settings under a name. On top of a variant, each reader keeps their own settings as a delta. The server applies the delta on every run, so a model upgrade that changes the variant keeps the reader's values and brings the vendor's new items.

← Developer wiki · user guide: Build a report

What the layout carries#

All additions to UserReportConfig are optional; a stored layout without them runs as before. A standard report built on a schema is stored whole; its file keeps only what it adds to the schema.

Field Where Meaning
id a grouping, a filter Stable id that settings refer to. A missing one is filled from the position: g{i} for a row grouping, gc{i} for a column grouping, f{n} for a filter (UserReportConfig.Normalize, withIds in the builder — the same rule). New items get random ids.
use a filter false switches the filter off: it imposes nothing, its value is not read, and the filter logic reads as if it were absent — «1 AND (2 OR 3)» with 2 off is «1 AND 3». A filter on the panel that waits for the reader's value is stored switched off (the builder does so on save); a filter that is on must have its value — the server refuses one without. The shipped-report test in ReportSettingsDeltaTests checks every standard report for it.
userMode the period, a filter, a grouping, a column quick (on the reader's panel), custom (in the settings), locked. Default: the period is quick, everything else custom.
options.runPolicy the report live (default) runs on every change, open on opening then on Generate, manual on Generate only.
options.variantsEditable the report false: readers may not save variants.
options.structureEditable the report false: readers may not change groupings, order, appearance or add filters (the settings dialog hides those tabs).
options.selectionTotals the report false: no totals of the selected cells.
options.drillReports the report Report ids (at most 8) a line opens in, narrowed to it (drillInto in drill.ts): the line's group keys and the report's filters go into the other report's filter on the same path — or onto its panel when it has none, or beside a locked one — a key on its period's field narrows the period, the period's dates come along otherwise, and a manual report runs on opening. A line of a hierarchy grouping filters inGroup. A double-click on a number opens the first.
bands the report Headers over several adjacent columns: { id, caption, captions }. A column names its band in band; a band no column names is dropped.
band a column The band whose header spans the column.
options.negativeRed the report true: negative numbers in red, in the window and the exports. A reader switches it in their own settings.
highlights[] the report Conditional appearance (ReportAppearance). The old form { columnId, op, value, color } paints a cell by its own number. A rule may also read another column (whenColumnId), compare a text with values (op in / nin), paint the whole row (target: "row") and carry a style (background, color — a palette name or #RRGGBB — and bold). The first match wins; a cell rule wins over a row rule.
context the report or a variant The card that lists it: { kind: "Dictionary" | "Document", metaId, path }, path being the report's field that holds the card's record (MetaId for the object itself). GET api/user-reports/context?kind=&metaId= returns the reports and variants the caller may open that name that card, each with its layout; the card adds a locked filter path = record.
values a group formula column The texts the formula returns (IF(…, "Not paid", …)): the column is then text, and a group filter on it ticks these texts.
valueCaptions a group formula column What each of values reads per language: { "notPaid": { "en": "Not paid", "uk": "Не оплачено" } }. The formula returns the code, the result carries the reader's text in <column>__label, and filters and ticks keep comparing codes, so a shipped report reads the same in every language.
options.mainGroupsOnly the report With additional sources: the groups come from the report's own object only. A group only a source has — its record count, which is the main source's, is 0 — is dropped before the group formulas run, and the groups above are totalled again. With it on, a source that maps a deeper grouping but not one above it (ReportFacts.LookupLevel) is summarized by that grouping alone and read per key: its figures go onto that level's lines and are added up through the levels above (the order's debt under the order's agent). A source is then read for the report's own groups only: the keys of every grouping it maps travel with its query (one JSON parameter per level, at most 100 000 keys each; an empty reference and no reference count as one key), so a source of every invoice ever, grouped down to an order's items, reads the invoices of the orders shown and is not cut by the summary's row limit. A source that stops above the report's deepest grouping warns about it only when one of its columns is visible: a hidden helper column feeding a group formula stops there by design.
fields[] a row grouping Extra fields: { path, placement }, up to 6. The summary reads each once per group as MAX(<path>) (a reference as text, a yes/no as a number) under the alias x{grouping}_{field}; the shaper keeps it on the grouping's own lines only. placement empty puts it after the group's name, «Customer — code, status»; separately adds a result column of kind extra with the grouping's level, filled on those lines. A reference or an enum gets its name in x…__label.
groupFilters[] the report «Show groups where»: { id, columnId, op, value, values, level, use, userMode }. op compares a number (gt … ne; empty counts as 0) or the shown text (in / nin with values). level is the grouping it applies to, 1 = the outermost; empty = the innermost. Levels are judged from the deepest up, the group formulas worked out again in between, so a customer is judged by the orders that passed. use: false, or a list without texts, imposes nothing. Ids fill as gf{i}.
root.kind: "RegisterBalance" the report or an additional source An accumulation register's balance and turnovers (ReportObjectKinds.RegisterBalance, 1C's «ОстаткиИОбороты»). Fields: the dimensions and analytics; MovementDate, the period, where anything before the start counts as the start; DocumentMetaId, the recorder, empty before the start; and per resource <Resource>Opening, …Income, …Outcome, …Closing, …Turnover (balancePart and timeAxis in the field tree). The rows are the movements up to the period's end, and each field splits them at the start (ReportBalanceSql, whose {from} / {to} placeholders the compiler fills with the period — or a KPI's comparison period — in Finish). Grouped by MovementDate (any bucket) or DocumentMetaId, the opening and closing balances are carried by a running sum over the grouping sets (ReportQueryCompiler.CarryBalances), so a line opens where the one before closed and a month total carries what did not move that month; a recorder is placed by its earliest movement (sq, ReportSummaryQuery.SeqLevels). A balance or turnover is a Sum. Refused: the table format and records under groups, a row filter on a balance or a time field, a row formula reading a balance along a time grouping, a debit/credit split along one, a recorder across a matrix, balanceAt. Lines whose figures are all 0 are dropped. The catalogue lists the root beside every accumulation register's movements. A period that starts within the last year is read through the register's balance table instead of all history — the current balance less the movements since the start (ReportBalanceSql.Union, ReportBalancePlanner) — when the report cuts only by what that table keeps, the reader has no row security on the register, and the table adds up to the movements (ReportSchemaService.BalanceTableAgreesAsync, checked every 5 minutes).
a register's id as a report id api/user-reports/{registerId} and its /variants, /my-settings, /duplicate The register's own report (RegisterReports, variant host kind Register): every resource's four figures by the first dimension for this month; its standard variants are the register's saved layouts (*.view.json) converted on read by ReportViewConverter, keyed by the layout's id, so a menu item naming a layout opens that variant. Readers keep settings and personal variants on it; nobody edits it here. POST api/registers/{id}/report — the register report's old API, which tiles, the hover card, the mobile desk and the assistant call — is answered by the same engine through RegisterReportAdapter.
groupCols[] a matrix Column groupings, outermost first, up to 3 (UserReportService.MaxColumnGroups): the headers of a grouping sit over the next one's. Each is a { path, bucket, sort } like a row grouping (no extra fields and no hierarchy); a group's own order is its sort. The same value under two parents is two columns. One entry is the matrix as it always was.
options.columnSubtotals the report A matrix with several column groupings: false leaves out the subtotal column of each group above the last grouping; empty or true shows them.
latest an additional source true: the latest record per key up to the period's end — 1C's latest slice (срез последних), the price in force on the report's date (ReportFactSpec.Latest). Needs periodPath; refused with balanceAt and on a RegisterBalance source. The source is read by key at the deepest grouping it maps, whatever the groupings above and mainGroupsOnly (ReportFacts.LookupLevel): its query groups by that key and by periodPath up to the period's end (a record without a date counts, as in force all along — ReportPeriodSpec.OrEmpty), and ReportFacts.Lookup keeps each key's row with the latest date (a row without a date is older than any dated one). Its figures go onto that level's lines and up through the levels above by their aggregate — a Max price shows the largest price of the group.
agg: "Sum" a group formula column A summed formula: worked out on the lowest lines and added up on every line above them, as 1C totals a resource (ReportResultShaper.IsSummed). «Quantity × price» is then right on a store or an item group too, not the store's quantity times its largest price. Group formulas without it are worked out on every line, as before; any other agg is refused. A summed formula reads the figures of its own line — fields, row formulas, sources and the summed formulas before it; a plain group formula reads the summed figure. One that reads a source grouped by fewer levels is worked out on the deepest level that source reaches and on every line below it, and added up above (ReportResultShaper.SummedLevels): an order's left to pay, out of its debt on the settlements, is right on the order with its items listed under it, and summed over a customer's orders.
factPaths a filter The same condition in each additional source: source id → its path for the field, as on a grouping. «Customer → Counterparty is X» on the receivables then narrows the payables by Supplier.Counterparty too (ReportFacts.FiltersFor): the filter is added to the source's own ones with AND, while it is on. A report with filterLogic keeps its filters to itself — an OR cannot be carried over filter by filter. Without it a source is not narrowed by the report's filters at all.
caption, captions a grouping The grouping's header instead of its path's captions (captions per UI language wins). A grouping that also stands for a source's path reads what both are — «Counterparty», not «Customer → Counterparty».

A matrix with several column groupings runs one query: every grouping set carries all the column keys or none (kc, kc1, kc2 → gc, gc1, gc2, one flag ggc; ReportQueryCompiler.Summarize), so the cells are the leaves and the line's total is the set without them. The subtotal of a column group is the shaper's: on every line, the cells of the group's leaf columns are added up under the group's own key (ReportResultShaper.AddColumnSubtotals) — sums and counts add, minimum and maximum are taken again, and an average or a distinct count, which cannot be rebuilt from parts, stays empty (the rule the hierarchy folders follow). Debit and credit sides add up as they do on the rows. A balance at a moment (opening and closing) does not add across periods, so when a column grouping is the period of a register's balances those columns have no subtotal. Group formulas run after the subtotals, so a ratio is worked out from the subtotal's own figures. An additional source follows the columns only when it maps every column grouping (factPaths); otherwise its figures land in the row totals.

The run result tells the columns as a tree: columnGroups lists the groupings (columnGroup stays the first), columnKeys the first grouping's values, each with children — the next grouping's values under it — and, with several groupings, an id (the keys of its path joined with U+001F) under which its cells sit on a line (cells[id]); a group above the last grouping has subtotal: true and a cell under its own id. With one grouping nothing changes: no id, no children, the cell is cells[key]. A drill-down from a cell names every key of its column path (DrillContext.columnKeys); a subtotal names a prefix, the total column none. The exports read the layout from ReportMatrixLayout: nested merged headers in XLSX, «Group / Customer» captions in CSV; matrixColumns.ts is its twin for the window.

The run result repeats what the renderers need — bands, each column's band, appearance and negativeRed — so the XLSX, CSV and mail exports paint the same way as the window without reading the layout. A reference whose record is gone gets the label <object not found> (…tail of the id) in the reader's language (ReportText.NotFound), as 1C shows it, rather than a bare id.

Where variants live#

Kind Stored in Who sees it Who changes it
Main (key "") the report itself everyone who opens the report the report's editors
Standard MetaStandardReports.VariantsJson, in the model file everyone the model, through workspace export and import
Shared MetaUserReportVariants, IsShared = 1 everyone who opens the report its owner and the report's editors
Mine MetaUserReportVariants, IsShared = 0 its owner only its owner

A standard report's variants travel inside its Reports/Standard/<Name>.userreport.json:

"variantsJson": "[{\"key\":\"unpaid\",\"captions\":{\"en\":\"Unpaid\",\"uk\":\"Неоплачені\"},\"configJson\":\"{…}\"}]"

A variant's root must be its report's root. Deleting a report deletes its variants and the readers' settings.

Variants in the menu#

A menu item of a standard report unfolds into the report's variants, as 1C lists a report's saved settings under it. GET api/metadata/menu/my puts on such an item variants: [{ key, name, kind: standard|shared|mine }] — the standard ones in the model's order, then the shared ones and the caller's own by name (ReportVariants.ForMenu); the report's own layout is not listed, the item itself opens it. An item of a report without variants carries none.

  • Ribbon: in a dropdown, the report is a submenu — the report itself, a divider, then its variants; a report placed straight on the band becomes a dropdown with the same entries.
  • Nova: the report's row has a chevron that shows its variants under it (folded by default); a variant can be a favorite, and the palette finds it by its name as «Report — Variant».
  • A variant entry opens the report's tab on that variant (MenuOpenParameters.variantKey → UserReportWindow.initialVariantKey); the report and its variants share one tab, which a click on another entry reopens on that variant.

A variant saved or deleted in the report window refreshes the menu (VariantPicker invalidates menu-my).

The reader's settings#

MetaUserReportUserStates keeps, per user and report, the variant open last and a delta per variant: { "<variantKey>": delta }.

{
  "period": { "relative": "LAST_MONTH" },
  "filters": { "f3": { "use": true, "op": "in", "values": ["…"] } },
  "groupFilters": { "gf0": { "values": ["Not paid", "Partly paid"] } },
  "hidden": ["c5"],
  "shown": ["c7"],
  "options": { "grandTotal": false },
  "collapsedLevel": 2
}

ReportSettingsDelta.Apply changes values only: the period, a filter's use tick, comparison and value, a group filter's tick, comparison, number and texts, which columns show, and the report options (grandTotal, subtotals, showDetails, hideEmptyGroups, negativeRed). It never touches the root, the sources, a column's field or formula, a grouping, or a group filter's column or level. Locked items and ids the variant no longer has are skipped and listed. A hidden column is still computed, so formulas still see it.

The settings dialog#

Customize… (frontend/src/pages/userReports/customize/) edits a draft: the variant with the reader's delta on top. On OK, splitChanges(variant, draft, prior) in customizeOps.ts splits it:

  • the values a delta can carry go through the same with* helpers as the quick panel (settingsDelta.ts), so an entry equal to the variant's own value drops out;
  • everything else is structure: the draft and the variant are compared with those values taken out (stableJson, keys sorted, empty entries dropped, an unwritten sort read as ascending). Any difference means structure.

Structure is never written into a delta. A saved report keeps it as a variant of the reader's (SaveVariantModal, then opened(key)); an unsaved one, opened by Analyze or a drill-down, takes it into its own layout. variantConfigOf switches unfinished filters off, drops new filters left without a value, and adds a new filter to the variant's own filter logic with AND, since the logic must name every filter. A reader removes a variant's filter only when the variant has no filter logic; otherwise the use tick switches it off.

The Groupings, Sort and Appearance tabs, and adding filters, show when the reader edits the report, or when options.structureEditable is not false and the reader may save variants.

API#

Call Does
GET api/user-reports/{id}/variants { variants: [{ key, name, kind: main|standard|shared|mine, canEdit, config }], canShare, canSave }
POST api/user-reports/{id}/variants { name, isShared, config } → { key }. Personal: anyone who may open the report, unless variantsEditable is off. Shared: the report's editors.
PUT / DELETE api/user-reports/{id}/variants/{key} The variant's owner, or the report's editors for a shared one. Standard variants change with the model.
GET api/user-reports/{id}/my-settings { lastVariantKey, settings }
PUT api/user-reports/{id}/my-settings { variantKey, delta }; an empty delta drops the variant's settings.
DELETE api/user-reports/{id}/my-settings?variantKey= Back to the variant as its author made it; all=true drops every variant's settings.
POST api/user-reports/run (and export) { reportId, variantKey?, settings? } runs a variant with a delta, applied by the server. A request that sends config runs that layout as before.
POST api/user-reports/export?format=xlsx|csv|pdf The file of a run. Besides the run request it takes title and variantName (the variant the reader has open, printed under the title of the PDF and the Excel file). pdf needs the print PDF service: 503 with a hint without it, 502 when it fails — see Print form PDF.

A mailing names its variant in variantKey and runs it with each recipient's rights, without personal settings. The variant must be one its owner can see.

Same topic for other readers: User

Was this page helpful?