For the complete documentation index, see llms.txt. This page is also available as Markdown.

Output

Print, mail, export and file documents, dunning letters, labels and notifications from scripts, and control outputs with output scripts.

Scripts use the same output system as a user clicking Drucken or E-Mail: output modules, report groups, output rules and consumers. A script can print or mail documents, dunning letters, labels and notifications, file them in the DMS or export them. An output script goes the other way and controls every output of a module before it is produced.


What Decides an Output

Part
Role

Output module

The kind of output, e.g. document print (Belegdruck), dunning (Mahnung-Listen), address notifications (Adress-Listen)

Report group

Layout and texts; a script selects it by its key

Output rules

Choose report group, output type and consumer for the module, the address and the user

Consumer

Delivers the output, e.g. a print server from VARIO Local Link or an e-mail consumer (Microsoft 365, SMTP)

Script outputs run without a browser. Printing therefore needs an output rule with a print server, and e-mail needs a rule with an e-mail consumer. Without them the output fails.

When the script sets no output type, the rules decide: the user's output preference, then the default output type of the address, then the general rules, then the module default. With the output type SYSTEM, VARIO Cloud tries the general rules of the module in the order of their priority and takes the first stage that is possible, for example e-mail if a recipient is found, otherwise print.


Services That Produce Output

Service method
Output

documentService.print(documentId)

Prints a document

documentService.sendViaMail(documentId)

Mails a document; recipients come from the output rules

documentService.sendViaMail(documentId, reportGroupIdentifier)

Mails a document with a specific report group, e.g. per customer language

dunningService.print(dunningId), dunningService.sendViaMail(dunningId)

Prints or mails a dunning letter

accountService.sendNotification(accountId, outputRequest)

Output in the module Adress-Listen for an address

crmDealService.sendNotification(dealId, outputRequest, eventConfig)

Output in the deal notification module

freePrintingService.printFreeReport(moduleKey, masterId, outputRequest)

Free report of a module for one record; returns the DMS reference of the result

articleService.newLabelPrintBatchIdentifier(), addLabelToPrintBatch(batchId, articleId[, serialNumberId], labelCount), executeLabelPrintBatch(batchId[, reportGroupIdentifier])

Collects article labels in a print batch and prints them in one go

printFreeReport() works for modules whose report groups support free reports. Module keys are listed by GET /cmn/output/modules. Other modules fail with "Das Modul … unterstützt kein freies Drucken".


Output Requests

Methods that take an output request get it from ctx.services.outputHelper.createOutputRequest(). The request is built with chained calls; everything that is not set is decided by the output rules.

Method
Description

outputMail(), outputPrint(), outputFileExport(), outputDmsOnly(), outputUserMessage()

Sets the output type

outputType(type)

Sets the output type by name, e.g. SYSTEM

groupIdentifier(key)

Selects the report group by its key

mailRecipient(emailAddress, alias)

Adds a mail recipient

userRecipient(userId, emailAddress, alias)

Adds a user as recipient

setUserId(userId)

Sets the user the output is produced for

exportFilename(name)

Sets the file name of an export

attachDocument(shelfDocumentId)

Adds a DMS document as mail attachment

arg(key, value)

Free placeholder, available in text templates as [(${arg$.key})]

Output Types

Type
Result

PRINT

Printed by a print server

MAIL

Sent by an e-mail consumer

FILE_EXPORT

Produced as a file in an export format

DMS_ONLY

Filed in the DMS only

USER_MESSAGE

Delivered as a message to a user

PREVIEW

Preview, only meaningful with a browser

SYSTEM

Resolved by the priority of the module's general rules


Output Scripts

An output script runs directly before every output of one output module, before the output rules are resolved. It can cancel the output or change output type, export format, number of copies and language. Output scripts are managed under Einstellungen → Allgemein → Ausgabe, at most one per module.

The script imports the module output_module_script and registers its callback with setBeforePrint(). The callback receives the context. Only an explicit true lets the output continue; false or no return value cancels it.

Context field
Description

ctx.dataprovider

Read-only values of the record, keyed by data provider name

ctx.outputType

Read-only output type that was requested

ctx.response.outputType

Overrides the output type

ctx.response.exportFormat

Export format, required when the output type is FILE_EXPORT: PDF, XLSX, HTML, JSON_RAW, REPORT_TEMPLATE or INVOICE

ctx.response.outputQuantity

Number of copies, overrides the quantity from the output rules

ctx.response.outputLocale

Output language as a language tag, e.g. de or de-DE

The response values only take effect when the callback returns true.

Typical uses: suppress printing for certain customers, switch to e-mail when a condition is met, print two copies for export deliveries, or produce documents in the customer's language.

Message
Cause

"Ausgabeart wird von dem Druckmodul nicht unterstützt"

ctx.response.outputType is set to a type the module does not support

"Die vom Skript gelieferte Ausgabe-Sprache … ist ungültig"

ctx.response.outputLocale is not a valid language tag


Files Instead of Reports

To produce a file in a format of your own, for example CSV or XML for a partner, use the writers described in Files & Export. The resulting DMS document can be attached to a mail with attachDocument().

Last updated

Was this helpful?