Business process designer > Document templates / Special functions of template syntax

Special functions of template syntax

The article describes the rules of using additional functions of template syntax:

  • Barcode to display the contents of a variable in a document as a barcode.
  • JobPosition to add the user's position.
  • PasteImage to insert an image in place of the variable.
  • HYPERLINK to convert the table content into a hyperlink.
  • ExtText to create a custom function for advanced features of working with the document template.

Barcode function

To encode a String type field in an app and add it to a document as a barcode, use the Barcode function. For instance, you can use it to generate a barcode for a contract’s registration number or another unique number assigned to a document. Later you can use this barcode to match the hard copy of a document with its digital version.

You can use barcode scanning software in BRIX if you configure an appropriate integration module. Read more about it in Standard modules and Introduction to Web API.

The system allows you to generate barcodes for Word and Excel files.

Syntax: GenerateBarcode(<text: srting:1>, <format: code format:2>, <height of the generaed barcode in pixels>). Specifying the height is optional.

  • [1]: the content of the string depends on the format specified in the second parameter.
  • [2]: available barcode formats and requirements to the string:
    • QR Code: Any string. Resolution up to 300 DPI is supported.
    • EAN-8: A string consisting either of 7 digits or of 8 digits (seven digits and a check digit).
    • EAN-13: A string consisting either of 12 digits or of 13 digits (twelve digits and a check digit).
       
      You can also add EAN format without specifying the type. In this case, the type of the generated barcode will depend on the number of digits in the sent string.
  • [3]: barcode height in pixels is an optional parameter. For correct recognition, the height is specified based on the number of characters used.

If the template uses the same string to generate a QR code twice, but specifies a different size, a QR code of the same size will be generated in both cases.

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

If no checksum was specified when using EAN formats, it will be added automatically. For correct operation, the barcode scanner must be configured to work with these formats.

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

It is recommended to use the QR Code format, as it can be applied to a greater variety of data, while the EAN formats are limited.

For example, there is a variable $numberstring, and its value is 5901234123457. From this string, a QR code or an EAN-13 can be generated.

начало примера

Examples

  1. {GenerateBarcode({$numberstring}, "QR Code", "125" )}.
  2. {GenerateBarcode({$numberstring}, "EAN-13", "125" )}.

конец примера

For an EAN-8, the string can only include 8 digits: $numberstring = "59012341".

JobPosition() function

This function is used to get a user’s job position.

Syntax: JobPosition(<param1: user>, <format:string>)

You can use the «first» variable to get only the first job position or the "all" variable to get all job positions of a user.

начало примера

Example

{JobPosition({$__createdBy},"all")} —> The function will pass all job positions of the user specified as the app item’s Author.

конец примера

 

PasteImage function

To paste an image from a context variable of the Image or Files type  into a document template, use the PasteImage function.

Syntax: PasteImage(<param1: image/file>, <width in pixels>, <height in pixels>, <crop instead of compression: true/false>)

Начало примера

Examples

  1. {PasteImage({$image})}. The image will be inserted with the original width and height values into the variable of the Image type.
  2. {PasteImage({$file.__id})}. The image will be inserted with the original width and height values into the variable of the Files type.
  3. {PasteImage({$image}, 200)}. The image will be displayed with a width of 200 pixels in the variable of the Image type. The height value will change, the original proportions will be preserved.
  4. {PasteImage({$file.__id}, 200, 400)}. In the Files type field, the function scales the image to a strictly specified size.
  5. {PasteImage({$image}, auto, 400)}. The image from the variable will be displayed with a height of 400 pixels. The width value will be scaled, the original proportions will be preserved.
  6. {PasteImage({$file.__id}, 200, 400, true)}. In the Files type field, the function will crop the image to the specified size without taking into account the original proportions.

Конец примера

HYPERLINK function for tables

When generating a template in a .xls and .xlsx file, you can use the HYPERLINK function. This is a standard Excel function that allows you to convert a given value into a hyperlink.

You can use variables of type String from the app context as arguments, as well as set values manually. For the function to work correctly, the full URL of the link is specified.  

Syntax: HYPERLINK("{$param1: string}" or "<complete url adress>";"{$param2: string}" or "<hyperlink value>").

начало примера

Examples

  1. =HYPERLINK("{$site}";"See the official site"). The site address is specified as a string in the app item, the hyperlink value is set manually.
  2. =HYPERLINK("https://elma365.com/en/";"{$__name}"). The site address is specified manually, the hyperlink value is formed from a field in the app item.

конец примера

ExtText function

In case system functions are not enough to customize a template, you can create a custom ExtText function. The function allows you to call API methods described in custom modules and apply them to the generated template.

Syntax: {ExtText("module id", "method address", {$additional parameter})}:

  • Module id. Characters from the module URL coming after /ext_. For example, if the module URL is mycompany.brix365.com/admin/extensions/ext_12ab-1212, then 12ab-1212 should be inserted into the function.
  • Method address. The value of the Address field from the table located on the API Methods tab in the settings of the module.
  • Additional parameters. An optional parameter that is passed to the specified method, for example, an app property. In the request body the additional parameters are displayed as p1, p2, etc. The are passed in the ExtText function separated with a comma after the mandatory parameters. Please note, the values will be assigned to the parameters in the order in which they are declared in the method request body.

Начало примера

Example

You can apply the ExtText function in naming app items. To do that:

  1. Create a module and set up an API method that will be used for generating app item names.
  2. Create a name template by using the ExtText function.

For example:

{ExtText("4c34-822c", "name", "Example text", {$_index})}

  1. The function will trigger the method that will process the passed parameters. After the conditions specified in the method are executed, the result can be used as an app item name.

Example of an API method script for creating app item names

Конец примера

When using complex custom functions, you can change their processing mode to speed up the generation of template documents. All variables and functions will be processed in parallel instead of sequentially one after another.

For this purpose, you can enable the enableConcurrencyTemplateMapper flag in some system editions:

After enabling the flag, you can set the number of parallel processing threads using additional parameters.