How to use multiple records with a socket or web service POST integration Follow

Avatar
Laura Vela

Overview

When sending data over a socket or in a web service integration, you have the option to send more than one record, much like a table structure with a file integration. This will allow you to send more information in one single trigger file.

When you create a new integration, it will only read and process one record. However, with some additional actions, you can direct the integration to process multiple records instead.

Note: When using a web service integration, this only works with a POST as it requires the data be sent using the body of the message.

Applicable to 

BarTender 2016 and above with Automation Edition and higher

Information

It is possible to send data over TCP or via POST that already has a "table like" structure, like the example below:

In order to be able to use the contents of "flat" files as variables, two additional actions are needed first: "For Each Database Record" and "Transform Text To Record set":

These two actions can be used "regardless of the ​type of integration" as it will use them based on the values of the %EventData% variable, this is the variable that saves all the incoming data for the integration.

The Transform Text to Record Set action can only accept text-based databases like CSV, tab-delimited, or other similarly delimited databases. More complex text-based databases such as XML or JSON won't properly work.

 

Setting up the "Transform Text to Record Set" action

The first action that needs to be defined is the "Transform Text to record set" action (this action will transform the data as a database like structure):

  1. First you will need to have a "sample" file that will be used to define the structure of the incoming data. For example, use a sample document with the same structure that is then going to be used on the sent data via TCP or POST.
    sampledb.png
  2. Click the "Database Connection setup..." button then use the wizard to link the "sample" database file to the integration. Once you've connected the database, close the dialog.
    transform.png

    transform2.png
  3. On the "Text Source" option make sure that the "Variable" is set to "%EventData%" and that the output is also "%EventData%". 
    transform3.png

This means that the data the action is going to use is the one on the variable "%EventData%" which is the one on which the integration is automatically going to save all the incoming data.

Setting up the "For Each Database Record" action

After the the data is split up into records, the integration will need to know how to handle these records coming in. The "For Each Database Record" with a "Print Document" action nested as its child will ensure that each record is printed individually during print time:
​​for_each.png
The "For Each Database Record" action requires no setup, however, you'll need to define how the data fits onto the label. This is done in the Print Document action.

  1. First, your label will need to have all the values set up with Named Data Sources.
  2. Click on the Import Document Settings button to import and fill in the Named Data Source names.
  3. Next, match the label's Named Data Source to the field names from the sample database. If you did not assign field names, they will be the auto-generated names of Field1, Field2, and so on.
  4. Select the variable icon in the Named Data Sources table to insert the name of the field from the dialog. The field names will be found under the Action section as shown below:

for_each2.png

If you know the field names, you can type them in manually in the syntax %FIELDNAME%.

Please sign in to leave a comment.