Advanced PDF print statement when a condition is met

Using advanced pdf, I am trying to modify a picking sheet to print a statement when {shipcomplete} is Yes. I am using the <#if> but have issues when the field is null.

I tried the following

<#if record.shipcomplete?has_content>

<#if record.shipcomplete == “Yes”>



When I do so, I receive the error below.

If the failing expression is known to legally refer to something that’s sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (!myDefault, (

I am not familiar with the myoptionalvar and do not know how to incorporate it into the picking sheet.

Any help will be greatly appreciated.

Rookie Asked on August 7, 2023 in Other.
Add Comment
6 Answer(s)

I think you are getting confused.
The error explanation is that you have a variable that may or may not be present / populated and in the explanation it’s called “myOptionalVar” i.e. “my variable that is optional”.

It’s explaining that you can use a default if your value is not populated like this:

myOptionalVar!!myDefault where “myDefault” is a  variable holding a default value to fall back on.

Alternatively you can use an IF statement with “??” to positively identify if a variable is populated.

I cannot recall the value of a checked checkbox in adv print, but the apache freemarker docs seem to imply it’s true or false

Not that this is your specific issue, it seems more likely the variable is not present.

Beginner Answered on August 8, 2023.
Add Comment

Thanks for your insight.  I have made the following adjustments.

<#if record?exists && record.shipcomplete?has_content && record.shipcomplete == “Yes”>

The template saves without an error, but I receive the “unexpected error has occured” when I attempt to print the picking sheet.  Any thoughts?

Rookie Answered on August 8, 2023.
Add Comment

Beginner Answered on August 9, 2023.
Add Comment

I have really tried to simplify the language, but continue to receive an error.  Any thoughts would be really appreciated.

<#if record.shipcomplete == “Yes”>

Rookie Answered on August 10, 2023.
Add Comment

I suggest you output the value to the page so you can see what it is you have.

Also, be aware if you work in different languages the comparison to “Yes” would also need to be “Oui”, “Ja” etc etc etc.

There’s a resolution for this as there’s a “builtin” for booleans.

As an example for you to try:
<#if record.record.shipcomplete?c == “true”>


Beginner Answered on August 11, 2023.
Add Comment

Changing Yes to true did the trick!  I really appreciate the help.

Rookie Answered on August 11, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor