Skip to end of metadata
Go to start of metadata


Create a field level script that prints (or does not print) a field based on the value of a key field. This is useful if you need to create a label with conditional fields or images that are dependent on the value of other fields on the label.
The effect of this type of script is to turn on or off the printing attribute of a field on the label.


Use the Example Label

This example uses the FieldLevelScript.lwl file attached to this article.
There are three fields on the label:

  • A script field that uses the Script Data Source, and contains the following example script.
  • The Variable field Print_Value, where we will enter the variable data that the script is going to run the logic against.
  • And the Print_Field which, depending on the value entered will either print or not print.


Example Script
//define variables 
var input1 = String(label.fields.field.(@name == 'Print_Value').@data);

//define if-else statement 
if (input1=="P" || input1=="p" || input1=="print" || input1=="PRINT" || input1=="true")  
   //print field
   label.fields.field.(@name =='Print_Field').@printingField = true;   
   //don't print field
   label.fields.field.(@name =='Print_Field').@printingField = false; 


  1. Save the example label to the Loftware Labeling/Labels folder or to your custom Labels folder.
  2. Open the label with Design32.
  3. Using On-Demand Print or File Drop, pass p, P, Print, PRINT or true to the Print_Value field. The Print_Field text should appear on the label.
  4. Print again, but pass a "false" value to Print_Value. The text will not appear, as the Print_Field has become a non-printing field.

Create a Label with a Field Level Script

  1. Create a new label, and add the following fields:
    • A scripting field
    • An input field
    • A field that will print or not print
  2. Modify the example script using the names of the fields on your label.
  3. Copy the modified script into the scripting field data source window (Loftware recommends creating scripts in a text editor such as Notepad and copying into the Data Source window).

Article Number



 Loftware Print Server Version and later


All supported installation environments.