ASP example
The ASP example is based on an ASP file, Custom Label Generator.asp, which is used to create a simple web application able to handle Pierbridge Label Requests and generate custom labels accordingly. This file can be modified to match the requirements of each project. The solution consists of the following files:
- CustomLabelGenerator.asp
- CustomLabelParameters.asp
- LogFile.asp
The CustomLabelGenerator.asp consists of the main logic of the custom label generator. Without any modifications the label generator will receive a request from the system that includes the data from Pierbridge Label Request. Append these to the appropriate thermal code and send back the custom label content. The label type is chosen based on the Format parameter, which is received with the label request.
Access request properties
TopThe Pierbridge Label Request data will be stored in a number of CustomLabelParameters that provide an easy access to each individual field through a property. If necessary, access to these parameters can be obtained by:
Dim parameters Set parameters = new CustomLabelParameters Dim filter filter = parameters.Field1
Adding custom parameters
TopIf additional data is required it can be looked up from any data source. In the examples these are the Shipping Order Header and Shipping Order Line Items tables. The connection details can be modified to match the server details:
Set connection = Server.CreateObject("ADODB.Connection") connection.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = My Database; User Id = myUsername; Password = myPassword;"
The example below shows how a value passed in through the Pierbridge Label Request in Field1 is used as a condition to lookup a Record Key One value from Shipping Line Items table. Please note that ShipmentID and PackageID parameters are also available for CustomLabel types through Pierbridge Ship Request. Required conditions or multiple return values should be added similarly to the sample below:
query = query & "SELECT [Shipping Order Line Items].[Record Key Six]" query = query & "FROM [Shipping Order Line Items]" query = query & "JOIN [Shipping Order Header]" query = query & "ON [Shipping Order Line Items].[Shipping Order Header ID] = [Shipping Order Header].[ID]" query = query & "WHERE [Shipping Order Header].ID =" & filter Set recordSet = connection.Execute(query) columnValue = recordSet(0)
Multiple labels
TopIf a single custom label generator is used to produce multiple labels, these can be identified by using the available CustomLabelName parameter and configured in the Administration App Data > Reference Data > Custom Labels.
Multiple labels with a same CustomLabelName can also be added to a single thermal label by creating a number of labels one after another:
‘label 1 label = label & "N" label = label & "OD10" label = label & "q812" label = label & "Q1218,24" label = label & "D15" label = label & "ZB" label = label & "A10,30,0,1,1,1,N," & "FROM" label = label & "A85,30,0,1,1,1,N," & parameters.SenderName label = label & "P1" label = label & "N" ‘label 2 label = label & "N" label = label & "OD10" label = label & "q812" label = label & "Q1218,24" label = label & "D15" label = label & "ZB" label = label & "A10,30,0,1,1,1,N," & "FROM" label = label & "A85,30,0,1,1,1,N," & parameters.SenderName label = label & "P1" label = label & "N"
Error logging
TopThe label generator uses a log file for error logging in case any error occurs. The error messages are written in a log file. The error log path is configured in the LogFile.asp file and should be modified to match the installation:
Dim log log = "C:\Temp\Custom Label Generator\ASPlog.txt"
Error messages are customizable and can be changed:
Call LogFile("No Data returned with: filter: " & vbTab & filter)
- Custom Label Generator toolkit introduces the toolkit and the role of Custom Label Generators in Transtream. It also covers basic use of the toolkit.