Wednesday, April 24, 2019

Hide Specific Line Items When Printing Transactions using Advanced PDF/HTML Templates

Advanced PDF/HTML Templates feature provides enhanced options for creating Printing forms. One of its advantages is the ability to include conditions in printing layout, so content can be customized on the fly depending on field values.

To hide specific items in the Item list on printing form, use HTML Source Editing feature. The HTML Source editor uses FreeMarker-based syntax, which is described in detail here: http://freemarker.org/docs/

For example, if you wish to hide Items containing "Bed" in their Item Names on Sales Order printing form, do the following:

1) Make sure Advanced PDF/HTML Templates feature is enabled
   a) Open Setup > Company > Enable Features > SuiteCloud
   b) check Advanced PDF/HTML (Beta) Templates under SuiteBuilder
   c) Save

2) Create a new Sales Order printing template
   a) Open Customization > Forms > Advanced PDF/HTML Templates
   b) Customize the preferred template or the standard one.
   c) Enter your Name for the template, for example "Test SO filtering template"
   d) In the template editor, click "Source" to edit Template XML source

3) Implement the filtering
   a) Find the code printing Item lines:

...
</#if>
 <tr>
 <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
 <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
 <td align="right" colspan="4">${item.rate}</td>
 <td align="right" colspan="4">${item.amount}</td>
 </tr>
 </#list>
...

   b) Add the filtering condition:

...
</#if>
<#if !item.item?contains("Bed")>
 <tr>
 <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
 <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
 <td align="right" colspan="4">${item.rate}</td>
 <td align="right" colspan="4">${item.amount}</td>
 </tr>
</#if>
</#list>
...

   c) Save the template

4) Apply the new printing form on your Sales Order Transaction Form
   a) In Printing Type, choose "Advanced"
   b) Choose "Test SO filtering template" in Advanced PDF/HTML Template
   c) Save

5) Open/create a new Sales Order using your customized Transaction Form and print the record. Items containing "Bed" in their names are missing in the list.

No comments:

Post a Comment