Reputation: 11
I have an Advanced PDF Template in NetSuite where we are trying to display a serial number list at the bottom of the document.
We have successfully filtered and displayed only serial-numbered items, but the issue I’m facing is that lot-numbered items are also being included in the list.
I feel like I’m very close but can't figure out what’s going wrong. I’m not very strong in FreeMarker, so any guidance would be appreciated!
The company uses both serial and lot items and we only want this logic to apply to serials items.
It would be a bonus if the heading "serials" hid if there was no serials table to render, but this is not the end of the world.
The code i have works until i try not to apply it to serial items
What we Tried: Checking isserialitem on the item record
When I added a condition to check tranline.item.isserialitem, it hid the entire list instead of just filtering out lot-numbered items. Adding a custom field (custcol_sga_is_serial_item) on the Item Fulfillment line
I created a True/False field to manually flag serialized items. When I used this field in the logic, it still hid the entire list instead of just filtering out lots.
The extra criteria i tried to add but all it did was remove the whole table was
<#if tranline.item.isserialitem?has_content && tranline.item.isserialitem?string == "T"> and also
<#if tranline.item.isserialitem?string == "T">
My current code where the list renders correctly but it DOESNT have a filter to apnly apply to serial items.
<tr style="background-color: #D3D3D3;">
<th colspan="3">Serial List</th>
</tr>
<#assign columnCount = 3> <!-- Number of columns per row -->
<#list record.item as tranline>
<#assign details = tranline.inventorydetail?split("<br />")>
<!-- Filter out valid serial numbers -->
<#assign validSerials = []>
<#list details as detail>
<#assign serialNumber = detail?keep_before(",")?trim>
<#if serialNumber != "" && !serialNumber?matches("(?i)X(\\s*\\(.*\\))?")>
<#assign validSerials = validSerials + [serialNumber]>
</#if>
</#list>
<!-- Only display the product section if there are valid serials -->
<#if validSerials?size gt 0>
<!-- Print Product Name and Description in Normal Style (No Grey Background) -->
<tr>
<th colspan="${columnCount}" style="background-color: transparent;">${tranline.item} - ${tranline.custcol_sales_description}</th>
</tr>
<#assign count = 0>
<#list validSerials as serialNumber>
<#if count % columnCount == 0>
<tr> <!-- Start a new row -->
</#if>
<td>${serialNumber}</td>
<#assign count = count + 1>
<#if count % columnCount == 0>
</tr> <!-- Close row when columnCount is reached -->
</#if>
</#list>
<!-- Close the last row if it's incomplete -->
<#if count % columnCount != 0>
<#assign remaining = columnCount - (count % columnCount)>
<#list 1..remaining as i>
<td></td>
</#list>
</tr>
</#if>
</#if> <!-- End check for valid serials -->
</#list>
Upvotes: 0
Views: 23