Understanding Filters

Loftware Automation uses filters to define structure of the data received by triggers. Each time a trigger receives data, one or many filters parse the received data. This process extracts relevant values for your configuration. Each filter includes rules to identify fields within received data.

[Note] Note

As a result, the filter provides a list of fields and their values (name:value pairs).

Configuring Structured Text Filter

Structured Text Filter

To learn more about filters in general, see section Understanding Filters.

Use this filter whenever you receive a structured text file. These are the text files in which the fields are identified by one of the following methods:

  • Fields are delimited by a character: Usual delimiter characters are comma or semicolon. CSV (comma separated values) is a typical example of a delimited file.

  • Fields contain fixed number of characters: In other words, fields are defined by fixed-width columns.

For examples of structured text data, see section Text Database.

Defining Fields

For structured text files, the definition of fields is very straightforward. There are two options:

  • Delimiter defines the fields: In this case, you have a delimiting character, such as comma or semicolon separating the fields. You just have to define the field names in the same order as they appear in the data received by a trigger.

  • Fixed-width fields: In this case, define the field names in the same order as they appear in the data received by a trigger, and define the number of characters the field would occupy. That many characters are going to be read from the data for this field.

UUID-c4da307f-9e87-8427-2a17-cb8cd383bd9a.png

Enabling Dynamic Structure

Structured Text filter has the ability to automatically identify fields and their values within the received data. This eliminates the need for manual variable-to-field mapping.

Configuring Unstructured Data Filter

Unstructured Data Filter

To learn more about filters in general, see section Understanding Filters.

Use this filter whenever a trigger receives non-structured data, such as documents and reports exported from legacy system, intercepted communication between devices, and captured print stream. The filter allows you to extract individual fields, fields in repeatable sub areas, and even name-value pairs.

For examples of the structured text data, see sections Legacy Data, Compound CSV and Binary Files.

UUID-4b1a2f40-6b83-c012-167b-05001fcbf3f4.png

Defining Fields

After you define a field, you have to define its name and rules for extracting field values from the data. When the filter executes, the extraction rules apply to the input data and assign result to the field.

UUID-396764de-d7c7-eb07-b0a9-5c287d870869.png

Defining Sub Areas

Sub area is a section of data that includes several blocks of data identified by the same extraction rule. Each data block provides data for a single label.

All data blocks must be identified by the same configuration rule. Each data block can contain another sub area. You can define an unlimited number of nested sub areas within parent sub areas.

If the filter contains definition of a sub area, the Use Data Filter action displays sub areas with nested placeholders. All actions nested below such placeholder execute only for data blocks at this level. You can print different labels with data from different sub areas.

UUID-c4dd13f8-55bd-7d17-4ce3-a62688c3940a.png

Defining Assignment Areas

Unstructured Data filter automatically identifies fields and their values in the received data. This makes manual variable to field mapping unnecessary.

UUID-0f008231-0a59-5d7a-0ffb-44f780894b31.png

Configuring XML filter

XML Filter

To learn more about filters in general, see section Understanding Filters.

Use this filter whenever a trigger receives XML-encoded data. The filter allows you to extract individual fields, fields in repeatable sub areas, and even name-value pairs. XML structure defines elements and sub elements, attributes and their values, and textual values (element values).

While you can define the structure of the XML file by yourself, Loftware recommends you to import the structure from the existing sample XML file. Click Import Data Structure button on the ribbon. After you import the XML structure, the Data Preview section displays the XML contents. It also highlights the elements and attributes that you define as output fields.

For XML data examples, see section XML Data.

Defining XML Fields

If you define XML fields, you make values of selected items automatically available. Filter definition makes such fields available for mapping to variables in actions. This allows you to extract values of elements or attributes.

To define an item value as field, do the following:

  1. Select the element or attribute in the structure list.

  2. For Usage, select Variable value.

  3. The item is displayed on the structure list with bold letters, indicating that it is in use.

  4. The element or attribute name is used as output field name.

  5. The Data Preview section highlights the value of the selected item.

UUID-135a1d20-812d-0a32-36a5-733c475fb1a5.png

Defining Repeatable Elements in XML Filter

If an XML element occurs in XML data for multiple times, it is a repeatable element. Usually, a repeatable element contains data for a single label. To indicate that you want to use data from all repeatable elements, and not just from the first one, define the element as a Data block and enable the Repeatable element option. If the filter contains definition of elements defined as data block / repeatable element, the Use Data Filter action displays repeatable elements with nested placeholders. All actions nested below such a placeholder execute only for data blocks at this level.

Defining XML Assignment Area

XML filter automatically identifies fields and their values in the received data. This eliminates the need for manual variable-to-field mapping.

UUID-deb86d18-4462-08c0-e508-0ed2be928521.png

Configuring JSON filter

JSON Filter

To learn more about filters in general, see section Understanding Filters.

Use the JSON filter if your trigger receives JSON-encoded data. JSON filter allows you to use variables and values from your JSON file. The filter supports data extraction from JSON arrays.

[Note] Note

Automation allows you to use all JSON data types. Read more about the available JSON data types here.

While you can define the JSON file structure manually, Loftware recommends you to import the structure from the received JSON files.

To import the JSON file structure:

  1. Go to Data Filters and Edit your JSON filter.

  2. Click Structure > Import Data Structure. Navigate to your JSON file and click Open.

    After you import JSON files, the Data Preview section displays the JSON contents. The Data Preview also highlights the elements that you define as output fields.

For JSON data examples, see section JSON Data.

Defining JSON Fields

If you define JSON fields, you make values of the selected items automatically available. Your filter definition makes such fields available for mapping to variables in actions. This allows you to extract the element values.

To define JSON fields:

  1. Select your element and set its Usage to Variable value.

  2. The element is displayed on the structure list with bold letters, indicating that it is in use.

  3. The element is used as output field name.

  4. The Data Preview section highlights the values of the selected element.

    UUID-9f0f03fd-7076-59f2-c647-ba1f51e713b0.png

Defining Repeatable Elements in JSON Filter

If a JSON element occurs in your JSON data multiple times, it is a repeatable element. Usually, a repeatable element contains data for a single label template. Repeatable items produce multiple labels populated with relevant data.

To indicate that you want to use data from all repeatable elements, and not just from the first one:

  1. Select the element and define it as a Data block.

  2. Enable the Repeatable element option.

UUID-8cd03b89-bc59-8a9a-0f71-cb27d3d850d8.png

If the filter contains definition of elements defined as data block / repeatable element, the Use Data Filter action displays repeatable elements with nested placeholders. All actions nested below such a placeholder execute only for data blocks at this level.

[Warning] Warning

JSON data filter with nested data block duplicates values from previous assignment area if a variable is defined in the first block but not in the second. For example, you print two labels. In the first assignment area, you defined a variable "manufacturer_serial". In the second assignment area, this variable is not present.

{
  "jobs": [
    {
      "data": [
        {
          "manufacturer_serial": "706583012001",
          "package_code": "AA792CY"
        }
      ],
      "label_filename": "serial_number_label.nlbl",
      "print_quantity": 1,
      "printer_name": "Warehouse_printer_09"
    },
    {
      "data": [
        {
          "package_code": "BE273XS"
        }
      ],
      "label_filename": "serial_number_label.nlbl",
      "print_quantity": 1,
      "printer_name": "Warehouse_09"
    }
  ]
}

The expected result would be the second label without "manufacturer_serial" data. But in the actual print, the second label would contain "manufacturer_serial" value from the first label, which is 706583012001.

There are three possible solutions:

  • Avoid nested data blocks.

  • Define variable values as empty values ("") if variables are not used in nested data blocks.

          "data": [
            {
              "manufacturer_serial": "",
              "package_code": "AA792CY"
            }
  • Use conditions on actions to set variables.

  • Use string manipulations when detected missing variables.

Defining JSON Assignment Area

JSON filter automatically identifies fields and their values in the received data. This eliminates the need for manual variable-to-field mapping.

UUID-8cd03b89-bc59-8a9a-0f71-cb27d3d850d8.png
[Note] Note

Because there are no optional attributes in JSON, Automation defines Variable names and Variable values automatically.

Setting Label and Printer Names from Input Data

Typically, filters extract values from the received data and send them to label variables for printing. In such cases, label or printer names are hard-coded into the actions. For example, Open Label action hard-codes the label name, and Set Printer action hard-codes the printer name. However, the input data can also provide meta-data. These are the values used inside the Loftware Automation processing, but not printed on the label, such as label name, printer name, label quantity, etc.

To use the values of meta-data fields in the print process, do the following.

  1. Filter reconfiguration: Define new fields for the input data to extract the meta-data fields as well.

  2. Variable definition: Manually define the variables to store the meta-data since they don't exist on the label and cannot be imported. Use intuitive names, such as LabelName, PrinterName, and Quantity. You are free to use any variable name.

  3. Mapping reconfiguration: Manually configure the Use Data Filter action to map meta-fields to new variables.

  4. Action reconfiguration: Reconfigure Open Label action to open the label specified by variable LabelName, and Set Printer action to use the printer as specified by the PrinterName variable.