in Advanced PDF/HTML templates for transactions, I...
# ask-stanley-ai
a
in Advanced PDF/HTML templates for transactions, I get an error instead of a PDF when printing the Picking Tickets, I think it's because the sales order they're from has dropshipped Purchase Orders on all of its transaction lines. I think I can fix the template to not error if it first checks whether record.item has no elements, is zero length, or something like that. What's the correct way to check record.item in freemarker, to determine whether there are no Item sublist lines given to the renderer?
c
AI generated answer (using internal Slack threads):
In Advanced PDF/HTML templates, you can check if
record.item
has no elements or is zero length by using the
?size
built-in function in Freemarker. This function returns the number of elements in a sequence or collection, or the number of characters in a string. Here's how you can use it:
Copy code
freemarker
<#if record.item?size == 0>
    <!-- Handle the case where there are no item sublist lines -->
<#else>
    <!-- Handle the case where there are item sublist lines -->
</#if>
In this code,
record.item?size == 0
checks if
record.item
has no elements. If it does, the code inside the first block is executed. If it doesn't, the code inside the second block is executed. Remember to replace the comments with the actual code you want to execute in each case. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
1
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.857327
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.855822861
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850312173
Please provide your feedback on this answer.
a
That fixed it! Thanks.
c
Thank you for your feedback