Skip to end of metadata
Go to start of metadata

 

← Back to the available automatic tasks list

 In case of any problems with understanding how the automatic task works, check: Automatic task, Conditional execution, Component parameters

Previous names: Document generation (till version 1.0.33) 

Category: Documents 


Description

Generates a document from the given template based on the current process data. Preparation of the document template is described here: DOCX template for generating PDF. The document can be attached to the process in which the automatic task was run. You can set your own name for the document and choose from one of two types - PDF or DOCX. The component allows you to set variable values in the template using the mapping. If the variables in the template already have the corresponding variables on the form, then using this component we can overwrite these mappings.

Configuration parameters

Parameter Name

From version

Description

Parameter type

Default value

Field type

Comments and restricitons

Format*

1.0.11

The file format in which the document will be generated.

Text

PDF

Non-editable dropdown list

Values to choose from: PDF, DOCX

Document class*

1.0.11

The name of the document class to which the generated document will be added. Note - the parameter must contain the original name of the document class, because translations are not supported.

Text

 

Editable dropdown list

Values to choose from: <names of document classes available in the system>

You can enter your own name, but if the component does not find a class in the system, it shows an error message.

Template*

1.0.11

The name of the template of the generated document. The template should be attached to the process in which we use the automatic task. The method of adding the template has been described tutaj (1.1.3) 

Text

 

Editable field

If it does not find a template in the system, the component throws the error information.

Attach*

1.0.11

Attaches the generated document to the process.

Logical

No

Non-editable dropdown list

 

New version*

1.0.11

Saves the document connected to the process as a new version. It works only when exactly one document with the same indexes from the same class is attached to the process

Logical

No

Non-editable dropdown list

 

Document names

1.0.24

Allows you to enter your own name for the generated document. If this parameter is not filled in, the system will generate the name itself.

Text

 

Editable field

If "/" or "\" is found in the name, the component shows an error message.

Key fields for mapping

1.0.11

The keys from the template that we want to map to the appropriate values given in "Mapping Values". For example, for the values in the template: "@ name @" enter the key "name"

Table of text values

 

Editable field

 

Mapping values

1.0.11

Values that we write, or over which we overwrite the variables declared in the template.

Table of text values

 

Editable field

 

Parameter*- mandatory field

Configuration example

Simple configuration (no mappings and with automatically generated name):

Advanced configuration:

Application example

 Example 1
Example

Let our need be to generate an invoice using values taken from the Plusworkflow system.

Document template preparation

Prepare a template that will be placed in our invoice process. A detailed description of building a template can be found on the DOCX Template page for generating PDF, and in this example we will use the following document:

 

We deal with a simple invoice, where we have to complete the invoice's identifier, the name of the customer to whom we issue the invoice, net, gross amount, and the name and surname of the person issuing the invoice.

The template is saved to the disk.

Adding an automatic task and configuration

On the process map add an automatic task that will generate the document at the right time. Choose the tab "Documents" and then "Generating a document from a template".

Empty configuration of the component is as follows:

  • We will now walkthrough all of the configuration parameters of the component:

    • Format - our choice is limited to PDF and DOCX, and in our example we assume that we want to get a PDF document. We leave the initial value.
    • Document class - we must select the class of documents responsible for invoices in our system. In this example, this is the "Invoices" class.
    • Template - the name of the template on the basis of which the document will be created. So far, we have not added it yet to the process, so we have a free hand in choosing the name. In the example, the template was named "invoice_suncode".
    • Attach - The template determines whether we want our document to be included in the process. Set to "Yes"
    • New version - If a new version of the document with the same name appears, we want to overwrite the old version of the document instead of adding a new one. Set to "Yes".
    • Document name - In this example, we want to know how the document with the invoice will be named. We want the next invoices to be called "invoice_suncode_1", "invoice_suncode_2", "invoice_suncode_3", etc., where 1, 2 and 3 are invoice IDs. To do this, we will use the concat function - which concatenates the given character strings. The first part of the string will be the phrase "invoice_suncode_", and the next value from the variable "Invoice Id". Finally, the concat function should look like this:

  • The next step is to properly set the mappings that we have prepared in the document template.
    - Invoice ID and customer name are saved on the form in the correct variables. Mapping works without any problems: 
     
    - The net amount and the gross amount appear on the form as floating point values. If you want to enter them into the parameter, you must replace them with a string. We solve this problem using the toString () function, which will convert numbers into text,

    - The last value to be set is the Issuer. In the template, we can see an unusual construction for this mapping:

    This is due to the fact that in this particular case we want to download from the form the user's login and the template generator is tasked to replace it with the name and surname of this person. This result is obtained using "@ fullname # <user login> @", where in the place <user login> you need to enter the mapping from the component configuration. In our case mapping is named issuer_login, so the configuration will be as follows:

Finally the configuration should look like this:

Save this configuration, connect the automatic task with other fields on the process map, and then export the process.

Adding a template to the process

Now that the process has been exported to the system, we can start adding the template. Go to the Administration -> Document flow -> Processes tab

In the list of available processes, we search for a process in which we placed automated task. Click on the "Edit" button next to the process name.

In the new view, go to the "Document templates" tab.

Click on the "New template" button. Fill in the values in a new window, giving the name from the configuration and the path under which we saved the template file.

We press "Add template". Ready.

Calling an automatic task

All steps necessary to use the automatic task have been completed. Time to start the process and save the values in the appropriate fields.

After filling the fields, we go to the automatic task that will generate the document. In this case, we will receive a document called “faktura_suncode_001.pdf”, which will be attached to the process. The body of the document should look like this:

The license could not be verified: License Certificate has expired!

  • No labels
Write a comment…