Reputation: 3
I'm using Freemarker in NetSuite's Advanced PDF/HTML templates to generate an Invoice. For specific item types, I want to display "1" instead of the actual quantity on the Invoice. This is based on the item category drop down field selection of "Services". My current attempt is below.
<#if record.custitem_item_category?string?contains("Services")>
<td align="center" colspan="3" line-height="150%">1</td>
<#else>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
</#if>
I tried validating the initial #if statement with ?has_content but it just skipped to the #else statement so think I've missed something there.
Upvotes: 0
Views: 519
Reputation: 181
Below thing works...
<#if item.colname=="Package"> (here you can set 1)
<#elseif item.colname=="Discount"/> (here you can set 2)
<#else>
Upvotes: 0
Reputation: 3783
From the field name custitem_xx
it sounds like you are trying to access a Custom Item Field. Two problems here. Firstly you need to read the value from each line (i.e. it should be item.item.custitem_item_category
not record.custitem_item_category
. But additionally (unless it's been recently fixed), doing so in NetSuite just returns the value from the first line of the sublist for every single line item.
What you need to do is create a Custom Transaction Line Field and source in the value from the item, which you would then access like item.custcol_item_category
.
[When you create the custom field, uncheck Store Value to make sure it is always sourcing in the latest value, and also make sure it is checked under Screen Fields on the form to display in the UI - otherwise it is not available to your template either. If you do want to hide it in the UI, you can just blank out the label.]
Upvotes: 1
Reputation: 1473
Your if statement looks correct, which means that record.custitem_item_category?string?contains("Services")
is not returning the value you think it is. Typically you would only use ?string
on a number to convert it to a string, if it is already a string, this is unnecessary.
Try just printing out ${record.custitem_item_category}
on each line and see what results you get. If some of them contain 'Service' then you should be fine with record.custitem_item_category?contains("Services")
in your if statement.
Upvotes: 0