RE: 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”>
SHIP COMPLETE
</#if></#if>
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: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
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.
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”>
https://freemarker.apache.org/docs/ref_builtins_boolean.html