NetSuite introduced FreeMarker Syntax in Advanced PDF/HTML Templates which gives users new options for their HTML and PDF forms.
One of the features is creating conditions with "if" statement. Here, it depends what data type the value is (integer, string, boolean).
Note: The codes in the following examples are part of standard Purchase Order template accessible under Customization > Forms > Advanced PDF/HTML Templates.
Example 1
Example value of boolean data type is "isclosed" column field in "item" list of Purchase Order. The following example shows how to filter only items that are not closed:
<#if !item.isclosed><tr> <td class="blrb">${item.item}</td> <td align="right" class="brb">${item.quantity}</td> <td class="brb">${item.units!}</td> <td class="brb">${item.description}</td> <td align="right" class="brb">${item.options}</td> <td align="right" class="brb">${item.rate}</td> <td align="right" class="brb">${item.amount}</td> <td align="right" class="brb">${item.isclosed}</td> </tr></#if>Example 2
Example value of integer data type is "item_index" which holds line number of currently processed line in "item" list of Purchase Order. Following example shows how to use this value for setting background color for each 2nd line:
<#if item_index%2==1> <tr style="background-color:#D6D3CB"> <td class="blrb">${item.item}</td> <td align="right" class="brb">${item.quantity}</td> <td class="brb">${item.units!}</td> <td class="brb">${item.description}</td> <td align="right" class="brb">${item.options}</td> <td align="right" class="brb">${item.rate}</td> <td align="right" class="brb">${item.amount}</td> <td align="right" class="brb">${item.isclosed}</td> </tr><#else> <tr> <td class="blrb">${item.item}</td> <td align="right" class="brb">${item.quantity}</td> <td class="brb">${item.units!}</td> <td class="brb">${item.description}</td> <td align="right" class="brb">${item.options}</td> <td align="right" class="brb">${item.rate}</td> <td align="right" class="brb">${item.amount}</td> <td align="right" class="brb">${item.isclosed}</td></tr></#if>Example 3
Example value of string data type is "item" column field in "item" list of Purchase Order. Following example decides if item name (in upper case) contains word "BEDROOM":
<#if item.item?upper_case?contains("BEDROOM")> <td class="blrb" style="color:blue">${item.item}</td><#else> <td class="blrb">${item.item}</td></#if>Note: There are two built-in functions used in this example - "upper_case" and "contains". For better understanding of functions please refer to FreeMarker Built-ins for strings (this is site is not maintained by NetSuite)
No comments:
Post a Comment