In this tutorial you will learn how to use the value expression editor. Each text element, barcode or two-dimensional code is designed to represent a value. You can set, program or calculate this value with the editor discussed in this tutorial.
Open the label template editor
You can use an existing template or create a new one for this tutorial. If you don’t know how to do it or you would like to learn basic information about the sizes and positioning of elements on the label, check out this this tutorial first.
As mentioned before, each text element, barcode or two-dimensional code is designed to represent a value. You may want to create a text element witch will act as a static label, dynamically changing variable representation or you may need to modify your data before printing, add some prefix, cut the text or make it uppercase. It is also possible to join static text, dynamic variables (placeholders) and use functions at the same time. All of these tasks can be achieved using the value expressions editor.
Open value expression editor
Add simple text element to the label template. When active, notice field Value expression on the element’s option panel. Click the pen icon to open the editor. As you can see, default static text value is set for each new text element.
With value expression editor you can add and remove parts of your expression as blocks of the expression using the plus and trash icons. After you finish building an expression, you should save it with Confirm button. Please notice meaning of the colors presented in the editor. They help you recognize purpose and type of each of the block. You can use static text, placeholder and function blocks. During expression assembly, you can also see the results in real time preview at the top of the expression editor.
Add new block to value expression
Please open the expressions value editor and try to add new static text expression using the plus icon next to the last block in editor. Enter random string in the static value field and confirm with round plus icon. Notice how the block is added to the expression and in preview.
Remove block from value expression
Please open the expressions value editor and try to remove one of the blocks. To do that, hover over the block you want to remove. You will see the red trash icon near the block. Use this trash button. Notice how the block is removed from the expression and preview.
Static text is mainly used to print fixed, immutable label elements. A good example would be the description of a dynamic text field or barcode. If you want to title one of your label fields, create a text element and create a static text expression for it, for example “Product code“.
Create text field used as “Product code” title
Static text
type.Product code
in the Static value
field.Confirm
button in the editor.Your Product code title field should be ready.
Placeholders represent dynamic values in the label template that will change for each printout. These variables will be provided depending on the method of managing printouts, by entering the data in the appropriate Excel form or by sending them in json format to the REST endpoint.
When designing a label, add placeholders to the template and give each of them a meaningful name, that will allow you to easily identify them in value expressions. It is also mandatory to set a preview value for each placeholder. This value will be displayed as expression value when designing your templates and will be replaced with the provided data during production use. Note that the placeholder cannot be shown as a separate element in the label. It is always part of the value expression of one of the elements such as text elements or barcodes.
Create a barcode representing the product code
Code-39
linear barcode element to your template and set some name to help you identify it.T
icon).productCode
Placeholder...
type.Choose placeholder
list. You should be able to locate your productCode
placeholder there.Confirm
button in the editor.Your Product code barcode field should be ready and should present the preview value of your productCode
placeholder.
Sometimes you will need to modify the data before printing it on the labels. For example, you may need to add a prefix to each barcode to help the WMS recognize the field type. You may also want to limit the length of the text to a certain number of characters. Otherwise, you may want to format the date, extract part of it, or make the text uppercase, lowercase, or capitalize each word. All these tasks can be achieved with expression editors built-in functions.
In the examples above we created a static text element with “Product code” title and a barcode element containing the actual product code. Please notice, that the barcode element converts it’s value to upper case. But what if you also need to print human-readable product code, and you want to present the code in capital letters, but you are not sure if the data you get will be properly prepared? The following example fixes this problem.
Create a text element representing the uppercase product code
We will use the productCode
placeholder from example in previous section. If you didn’t follow this tutorial before, add new text placeholder with the mentioned name or reference previous section.
productCode
placeholder’s preview value to be invalid. Set its preview value to some lowercase string (for example: p100rm23
)Function...
type.toUpperCase
function.toUpperCase
expects only one argument, the text that should be converted to uppercase.value
argument and choose placeholder type, then select your productCode
placeholder.Confirm
button in the editor.Your Product code text field should be ready and should present the preview value of your productCode
placeholder converted to uppercase.
As you probably noticed looking at the screenshot at the beginning of this tutorial, the value expressions can be quite complex and can mix all the features mentioned in this tutorial all together. Although in most cases it probably will not be needed to build such a complex expressions, it is good to know how to do this. With the knowledge you gained in previous sections, try to prepare one new text field which will use four placeholders. Set the new placeholders’ names and values as below. Please notice the lowercase product code and first and last name.
p100rm23
A long and very detailed description that can not be printed in full length
john
doe
Now let us remind you the target expression:
We want to create the expression which will join and format the given data to produce value containing
Create a text element representing the uppercase product code
To build expression, follow the steps:
Info:
” – please notice space at the end.toUpperCase
function and set its value with productCode
placeholder.-
” – please notice space at beginning and at the end.abbreviate
function and set its value with productDescription
placeholder and max size value with static text 15
.From:
” – please notice space at beginning and at the end.capitalizeWords
function and set its value with speditorFirstName
placeholder.
” – one character: space.toUpperCase
function and set its value with speditorLastName
placeholder.Confirm
button in the editor.The final effect should look like this:
Info: P100RM23 - A long v... From: John DOE