Business process designer > Graphical elements / Generate from File

Generate from File

generate_file_)The Generate from File activity uses a file from the context of an app or a process as a template to create a document. This is especially useful for cases when you have to choose from various templates when creating a new document.

For example, there is the Contract types app that stores different types of contracts with corresponding templates. In the course of the Place order process, an employee receives a task in which they specify the order data, select the contract type from the app, and send the order for processing. Then, using the Generate from File activity, a contract is created from the selected template file based on the entered data.

Use .docx and .xlsx files as templates. To learn more about the syntax used in templates, see Template syntax.

начало внимание

Only users included in the Administrators group can set up the Generate from File element.

конец внимание

Set up a process with the Generate from File activity

  1. The Generate from File activity works only with the process context variables. Therefore, to ensure correct operation, add properties for all types of contracts in the process context. For example, if a sales contract specifies a client and a warranty contract specifies a contractor, add both variables to the context.
  2. Also create variables of the Files type to load the input template file and display the finished document, for example, Template file and Generated contract.
  3. Add the Generate from File activity to the process diagram. Place it where the document needs to be created during the process execution.
    generate-from-file-4
  4. In our example, the employee will enter the data for the contract in the Place an order task. To transfer values, as well as the contract type selected by the employee, to the Generate from File activity, use the Assign Value graphical element. For example, place it after the task and name it Get template file and values ​​for contract. In the activity settings, match the app properties with the process context variables.
  5. To get a ready document for completing the Sign contract task, place the Generated contract process context variable on its form.
     
    You can also use the Assign Value activity and place it before the signing task. In its settings, match the process context variable with the app field for displaying the contract.

Set up the Generate from File activity

On the process page, go to the right pane and open the System Elements tab.

Drag the Generate from File activity to the process diagram and place it in the spot where you need the system to create the document.

Double-click on the activity to open its settings.

General tab

generate-from-file-02

  • Name*. Specify the name of the operation as it will be shown on the process diagram.
  • Input file *. Select the file that will store the document template. The compatible file formats are .docx and .xlsx. Only File variables can be selected.
  • Output file*. Select the file that will store the created document. Only File type variables сan be selected.
  • Generated file name*. Enter a name for the output file. You can use process variables and the DateTime() function. To add a variable, click {+} on the right side of the field. To use DateTime, click f(x). You can read more about using the functions in Template syntax. Also in the file name, specify the available format: .doc, .docx, .xls, .xlsx, or .rtf.
  • Convert to PDF. Enable this option if you want the document to be created in .pdf format.
  • PDF standard. This field appears when the Convert to PDF option is enabled. Select the desired .pdf format. The default option is PDF/A-1a. Other available formats are PDF/A-1b and PDF1.7.

Error Handling tab

An error may occur during document generation, for example, if the file creation service is unavailable. You can set the further course of the process and the actions to be performed in this case.

generate_file_2

  • Notification. Enable the option so that in case of an error, responsible users will be notified about it. You can select:
    • Current user. The one who performed the task placed before the Generate from File activity in the process diagram.
    • Context variable. For example, the initiator.
    • Group.
    • Org chart item.
  • Interrupt. Check the option and select the connector that the process will follow in case of an error.

After having filled out all fields, click Save.

The input template file is stored in the app context. The newly generated file is saved into the variable that you have specified as the output file. Add this variable to the appropriate task form or use it in a script to allow the user to retrieve the document.