The goal of this example is to create a Database Integration that uses an update to a SQL Server database table to trigger printing a BarTender document. The Integration Service passes the table's data into the document's named data sources and then prints each record.
A company has a backend database containing data they wish to print on their labels. A table or view can be generated so that when new records or data are added, it will trigger a printed label. This eliminates the need to utilize a middleware application to interface between the database and BarTender.
The following procedures describe how to set up, deploy, and verify the integration for the scenario outlined above.
Set Up the Data Files
- Create a SQL Server database table with the following entries:
- Name the database "TestDb" and name the table "Table_1".
Create the BarTender Document
- Open BarTender.
- From the File menu, select New to open the New Document Wizard.
- Select Blank Template, and then click Finish to close the New Document Wizard. A new document appears in BarTender.
- From the File menu, select Print to open the Print dialog.
- From the Name dropdown list, select the printer you want to use, and then click Close to close the Print dialog.
- Create two named data sources:
- On the Data Sources tab of the Toolbox, select Named Data Sources.
- From the Named Data Sources context menu, select Create Named Data Source to open the Create Named Data Source Wizard.
- In the Name field, type CompanyName.
- Click Finish.
- Click Close to close the Named Data Sources dialog.
- In the Toolbox, select Named Data Sources again and repeat the process. This time, create a named data source called IDNumber.
- From the Create menu, add a single-line text object to your document.
- From the Create menu, add a Code 128 type barcode to your document.
- From the text object's context menu, select Properties to open the Text Properties dialog.
- In the left Navigation Pane under Data Sources, select the data source you just created, currently called Sample Text.
- If it's not already open, click the Data Source tab.
- At the right of Name, click to open the Change Data Source Name Wizard.
- On the wizard, select Link to existing named data source.
- From the list of named data sources, select CompanyName.
- Click OK to close the Change Data Source Name Wizard.
- Click Close to close the Text Properties dialog.
- From the barcode object's context menu, select Properties to open the BarCode Properties dialog.
- In the left Navigation Pane, select the data source you just created, currently called 12345678.
- Repeat steps 11-16, this time connecting the barcode object to the IDNumber named data source.
- From the File menu, select Save As, and save the BarTender document under the name CompanyList.btw.
Create the Integration
- Open Integration Builder.
- Click Create New Integration to open the New Integration dialog.
- Select Database, and click OK to close the New Integration dialog.
- In the Database Integration pane, select Integration.
- In the Properties pane, enter the Name of your integration as "CompanyList".
- From the Start Integration dropdown list, select Automatic.
- Under User Account, specify user credentials. See Print document using an empty file for details.
- In the Database Integration pane, select New Record Detection.
- In the Properties pane, click Database Connection Setup to open the Database Setup Wizard.
- Select Microsoft SQL Server and click Next.
- At the right of Server, enter the server name.
- Select Specify user name and password (Database Authentication) and enter the username and password you wish to use.
- From the Database dropdown list, select the name of the SQL Server database you created the table "TestDb" and click Next.
- Select Use the wizard to build SQL statement.
- Add "TestDB" from the Available Tables list to the Tables to Use list and click Next.
- Select Record Browser to verify the correct data has been loaded. Click OK to complete the connection.
- In the Properties pane under New Record Detection Method, select Field has increasing value.
- From the Field dropdown list, select ID. Leave the Last value set at 0. This will execute the Integration for any database records after the specified last value and database field.
- In the Database Integration pane, expand the Action node and then further expand the For Each Database Record node.
- Select the Print Document action.
- In the Properties pane, scroll down to the Document section.
- At the right of Document, browse to and select the BarTender document you created earlier, CompanyList.btw.
- Under Named Data Sources, assign values to the named data sources using the variable database field names.
The Name column refers to the named data source set in the BarTender document, and the Value column refers to the actual value sent to the named data source. In this example, it would be the variable database field names of the database you are using in the Integration.
- Click in the top left corner of Integration Builder to save the integration file as DatabaseIntegration.btin.
Test the Integration
- At the bottom of the Integration Builder window, click the Test tab.
- At the top-right of the Test window, click the Start button.
- Since there are 7 new records in the database table, 7 documents should print.
- If the integration is working properly, click in the top left corner of Integration Builder to save the integration file.
The integration can now be deployed to Administration Console.
Deploy the Integration
- From the Integration Builder toolbar, click Deploy Integration to open the New Deployment dialog.
- In the New Deployment dialog, enter a name and description for your deployment.
- Ensure that the Integration File setting lists DatabaseIntegration.btin. Otherwise, click Browse and browse to and select
- For Target Servers, add the server(s) you want to deploy the integration file to.
- Specify the desired Error Handling settings.
- Click OK to close the dialog and deploy the integration file.
- Administration Console will open on the Integrations node, displaying your integration.