Display Total Discount Field Using Advanced PDF if Amount Is Greater Than Zero

Written by
Junica Ann Capili
Published on
December 27th, 2023

Scenario:

On the Advanced PDF/HTML templates of transaction records, the total discount amount is displayed using the variablerecord.discounttotal, but there are instances where the transactions do not have any discounts.

The solution below provides a snippet of code that allows the conditional formatting using source code. This allows the Total Discount field to bedisplayed only when the value of the total discount is greater than zero(0).

Solution:

  1. Navigate toCustomization>Forms>Advanced PDF/HTML Templates
  2. Preferred Transaction PDF/HTML Layout: ClickEdit/Customize
  3. Upper right corner: ToggleSource Code
  4. Add the below snippet to the preferred position of the field:
    <#if record.discounttotal!=0><tr><td align="right"colspan="2"><b>Discount</b></td><td align="right"colspan="2">${record.discounttotal}</td></tr></#if>
  5. ClickSave