ZPL | Custom Template : 'null' variables preventing Zebra function operating

Hey folks,

I ran into a ZPL issue today that caught me off guard,
-Looking to see if anyone can help me wrap my head around this one.

It seems that if a variable is populated with ‘Null’ the device function_Zebra Printer, Custom Template fails

This instance caught me off guard as we have used this button and device function for several months.
-In the past, if a variable = ‘Null’ the printed material would return a blank field.


One detail to note is that I was able to identify a difference in the Expression structure of my trigger function:

In the past, I structured the variables within the expression: [ AAAA|BBBB ]
-Whereas, when I was surprised to see the structure had been changed to: [ AAAA + ’ | ’ + BBBB ]
(I thought somebody rewrote expression at first :eyes: )

I am not sure if this change is in consequence to a recent update?
-Any insight is helpful.
(I am weighing if I need to create a substantial long-term solution to mitigate this roadblock.)

1 Like

Hey Dave,

I’m the engineer that worked on recent changes to Expressions. I believe that you were previously using Text Static Values with embedded variables, which allowed you to structure variables within the expression as [ AAAA|BBBB ] as you described. To clarify our product, since it’s unintuitive for variables to be a static value, any Text Static Values with variables in them were automatically moved to be Expressions instead in the latest release 205.

The downside to this, as you’ve discovered, is that a Static Value with a NULL variable automatically becomes a blank field, but not for Expressions. I think the simplest solution to have your function up and running again is to enclose any variables that may potentially be NULL with the Expression Editor LINK() function, described here: so instead of Variable.Selected.custbody54, you can write LINK(Variable.Selected.custbody54, '') so that if your variable is NULL, it will default to a blank string like before.

Let me know if this works, and apologies for the inconvenience!

1 Like

Hey Joonhok,

Thank you for following up!

I was able to apply the solution you advised and it worked!
-Thank you very much.

1 Like

Hello @joonhok ,

I saw this post and I believe you can help me understand the expression editor.
“Sometimes” when I add a variable string to a static string the variable is change to e{sequential number}. When it happens I’ve to start from the beginning and add string one by one.

Hello Patxi, Joon is out this week; I’m another engineer on the team.

It looks like the your current issue with e# is related to how the quotes are being used in the expression editor. The short version is that if you replace the single quote at the start and end of the expression with a double quote, it should start working.

The longer version is this. It looks like the expression editor is treating the entire expression as a string literal since it starts and ends with a single quote, and there are no single quotes throughout the body. If you replaced all of the double quotes with single quotes throughout, that would also work. I suspect the reason this happened is because the expression editor automatically replaces pairs of double quotes with pairs of single quotes. So if you are building the expression incrementally and only using double quotes, you might run into this. The more general fix is to always used single quotes when building expressions.

1 Like