2.12. Report Templates
2.12. Report Templates
The system allows you to create reports that can be used as templates when sending notifications (in user tasks and in service tasks for sending email). Reports support the use of task and document attribute values, as well as other system entities (via code).
To create a report template, in the navigation panel of the Studio workspace, select the Developer Tools folder, then Report Templates, and select Add.
On the General tab, fill in the fields described in the table below, then select Save.
| Field | Description |
|---|---|
| Model* | Enter the model code. For custom templates, it is recommended to use the code cust. |
| Report Code* | Report code |
| Name* | Report name |
Fields marked with * are required.
After saving the report, the Template tab provides an HTML editor where you can create the template content.
You can use task and document attributes in the template text. The following syntax applies:
- for standard task attributes:
{{task.сode}}, example:{{task.description}} - for standard document attributes:
{{ instance.сode }}, example:{{ instance.docNumber }} - for custom document attributes:
{{ instance.attrValues.сode }}, example:{{ instance.attrValues.country }}
You can also send a file attachment from a document file attribute (Document Image, File, Document Attachments, Collection). To do this, create a report template and add the following code on the Code tab:
const {emailAttachmentLoader} = require('@unitybase/dfx')
exports.reportCode = {
buildReport(data) {
data.addAttachment(
emailAttachmentLoader.loadNativeAttribute({
// documentID: data.task.variables.$ID,
documentID: data.task.objectID || data.task.variables &&
data.task.variables.$ID,
// documentID: data.process.objectID,
attribute: 'docImage',
PARAMETERS
})
)
return this.buildHTML(data)
}
}
The code uses the following parameters:
emailAttachmentLoader.loadNativeAttributeoremailAttachmentLoader.loadAttributedepending on the file attribute type (Standard or Custom)attribute— attribute code
Examples:
Document Image: emailAttachmentLoader.loadNativeAttribute, attribute: 'docImage'
Document Attachments: emailAttachmentLoader.loadNativeAttribute, attribute: 'attachments'
File attribute: emailAttachmentLoader.loadAttribute, attribute: 'a001', where a001 is the attribute code
PARAMETERS — specify additional parameters for the file here. The list is provided in the tables below.
The converted parameter
Send a converted or original file (for doc/docx).
| Value | Description |
|---|---|
converted: true | The converted file will be sent. Example: if a docx file is uploaded to the attribute, a pdf will be sent. |
converted: false | The original file will be sent. Example: if a docx file is uploaded to the attribute, a docx will be sent. |
| parameter not set | Same as converted: false |
The signatures parameter
Send signatures along with the file.
Signatures can only be sent with the original file that was signed. Therefore, the signatures parameter cannot be used with converted: true. You can use converted: false or omit the converted parameter.
| Value | Description |
|---|---|
signatures: true | The original file will be sent together with its signatures. |
signatures: false | Only the original file will be sent. |
| parameter not set | Same as signatures: false |
signatures: 'container' | Sends signatures from PDF files as a container. If the file is not signed, only the PDF file will be sent; if signed, the file and signature will be sent in a container. Can only be used if the original file is in PDF format. ℹ️ Note: This parameter cannot be used together with converted and signatures: true/false. |
The zip parameter
Send the content as a zip archive.
Can be used together with the converted and signatures parameters.
| Value | Description |
|---|---|
zip: true | A zip archive will be sent. |
zip: false | Unarchived attachments will be sent. |
| parameter not set | Same as zip: false |
The version parameter
Send a specific version of the file.
| Value | Description |
|---|---|
version: 2 | Version 2 of the file will be sent. |
Examples
Sending a Document Image with Signatures as a Zip Archive
const {emailAttachmentLoader} = require('@unitybase/dfx')
exports.reportCode = {
buildReport(data) {
data.addAttachment(
emailAttachmentLoader.loadNativeAttribute({
// documentID: data.task.variables.$ID,
documentID: data.task.objectID || data.task.variables &&
data.task.variables.$ID,
// documentID: data.process.objectID,
attribute: 'docImage',
converted: false,
signatures: true,
zip:true
})
)
return this.buildHTML(data)
}
}
Sending Document Attachments as a PDF Container
const {emailAttachmentLoader} = require('@unitybase/dfx')
exports.reportCode = {
buildReport(data) {
data.addAttachment(
emailAttachmentLoader.loadNativeAttribute({
// documentID: data.task.variables.$ID,
documentID: data.task.objectID || data.task.variables &&
data.task.variables.$ID,
// documentID: data.process.objectID,
attribute: 'attachments',
signatures: 'container'
})
)
return this.buildHTML(data)
}
}
Sending a File Attribute with Code a001, Version 3, with Signatures
const {emailAttachmentLoader} = require('@unitybase/dfx')
exports.reportCode = {
buildReport(data) {
data.addAttachment(
emailAttachmentLoader.loadAttribute({
// documentID: data.task.variables.$ID,
documentID: data.task.objectID || data.task.variables &&
data.task.variables.$ID,
// documentID: data.process.objectID,
attribute: 'a001',
signatures: true,
version: 3
})
)
return this.buildHTML(data)
}
}
Sending Version 2 of Files from the "Document Attachments" Attribute
const {emailAttachmentLoader} = require('@unitybase/dfx')
exports.reportCode = {
buildReport(data) {
data.addAttachment(
emailAttachmentLoader.loadNativeAttribute({
documentID: data.task.objectID,
attribute: 'attachments',
version: 2
})
)
return this.buildHTML(data)
}
}
2.12.1. Send an Email Using a Report Template
Report Templates is a legacy feature. You can use Email Templates instead, which is the modern equivalent of the same functionality. However, if you still want to use Report Templates, follow these steps:
-
Open the business process definition whose notifications you want to configure.
a. In the navigation panel, select the Studio 1 workspace.
b. Select the Process Library 2 shortcut.
c. Select the required definition 3. -
Select the icon to open the modeler settings.
-
Uncheck Hide the ability to use reports in notifications 1, then select the Apply 2 button.
After that, you can use report templates as usual:
-
On the process form, select the user task 1 from which you want to send a notification.
-
In the task settings, expand the Notifications 2 section, then in the Assign from 3 field, select Report Template.