Script to ignore null values from data source

Software technical issues not related to any of the other categories

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
Tony B.
Posts: 1
Joined: Mon Jul 19, 2021 3:45 pm

Script to ignore null values from data source

Post by Tony B. » Mon Jul 19, 2021 5:15 pm

I have a working template for label generation that is functioning fairly smoothly, except for when a null value is encountered in a specific data source. What will happen then is the label preview generation will fault due to the null value and stop the string of labels until the data source is fixed, or the item is unchecked. This can cause a delay and loss of efficiency. It's my theory that there is probably a way to script a function that can act as a filter on the data source, so that if it encounters a null value, it will display "blank", or could be substituted with a different data source. Ie:

If: Vendor items = null,
then: display blank

#or -
If: Vendor items = null,
then: Display "Inventory.Store\item number"

I was experimenting with this in Python, but I haven't had enough experience with it to get the syntax correct or to know the basic functions. Any ideas?

User avatar
NiceLabel Support
NiceLabel Support
Posts: 228
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin

Re: Script to ignore null values from data source

Post by Mytch » Fri Jul 23, 2021 4:47 pm

Tony B.,

You can check this article to start: ... web--cloud

And determine if the value you are checking is really NULL or actually just blank. Most empty data source values in NiceLabel will be treated as an empty string (''). So if you want to check some variable value in Python, you would do something like:

Code: Select all

if Variable.Value == '':
	Variable.Value = 'not blank anymore'
python.png (38.64 KiB) Viewed 10 times

Note the difference between checking a variable value and setting it. Python Function can be used to directly set a variable value output or sets its own result as the output of the Function using Result.Value.


Post Reply