Skip to content

Default Template

The invoice template is the model based on which the PDF copy of an invoice is rendered. It defines its contents and layout. The produced PDF document is intended to be distributed via email or postal service to customers, and it can be exported and archived. JustOn provides a default template, based on which you can define your own templates.

Template Structure and Building Blocks

The template is composed of a number of pre-defined containers that represent specific areas of the page - the header, footer, the invoice line item table, etc. Each container comprises text blocks that define the actual content displayed in the final document. For example, the header container contains text blocks for including addresses for sender and recipient, a company logo, and other invoice details.

Text blocks can include placeholders. These are symbols for fields of Salesforce or JustOn objects (like address fields or payment data), which are to be replaced with actual values upon PDF rendering.

PDF Contents

The following graphic illustrates the commonly used template building blocks and their (default) position. Using custom CSS (see CSS Rules), you can adjust the positioning, layout, etc. according to your needs.

invoicepdf

Position Template Field Description
1 Notes & Attachments The image file attachment set as the company logo to be rendered within the header
Page Header Is displayed at the top of each page (except for the first one) and can be used to display a page counter.
2 Header Defines the header area printed on top of the first page of an invoice. Commonly used for including a company logo, contact information and other invoice details, like a customer account number.
3 Sender Address Defines an area for printing the sender's address, usually positioned above the recipient's address.
4 Recipient Address Defines the area for printing the recipient's address. Using placeholders, you specify the address information to be printed.
Billing Address Defines an area for printing the billing address, which is printed if it differs from the recipient's address.
5 Display Type Specifies the type of the invoice to be printed to the PDF, like Invoice, Credit Memo, Reminder.
6
7
Info Left
Info Right
Define areas for printing a page counter, the invoice number and the invoice date above the actual invoice text.
8 Text 1 Text to be rendered above the invoice line item table, can be used, for example, to edit a letter-like text introducing the invoice that follows.
9 Table Columns Defines the columns for the invoice line item table. The definition must be a list of invoice line item field names separated by semicolons. A column can display the concatenated values of multiple item fields. To concatenate fields, use the plus sign.
The default definition, which is used when the field is left blank, is:
PosNo;Title+Description;Quantity+Unit;UnitPriceNet;Discount;PosTotalNet;
Subtotal (net) Label Defines the display of the subtotal (net) information, which is rendered as part of the invoice calculation below invoice line item table. Can contain placeholders, like Subtotal [ProductGroup].
If empty, defaults to the custom label SubTotalNet.
Subtotal (gross) Label Defines the display of the subtotal (gross) information, which is rendered as part of the invoice calculation below invoice line item table. Can contain placeholders, like Subtotal [ProductGroup] (gross).
If empty, defaults to the custom label SubTotalGross.
Subtotal Without Discount (net) Label When showing the order discount, defines the display of the subtotal (net) information without discount, which is rendered as part of the invoice calculation below invoice line item table. Can contain placeholders, like Subtotal [ProductGroup] (net).
If empty, defaults to the custom label SubTotalNetNoDiscount.
Subtotal Discounted (net) Label When showing the order discount, defines the display of the discounted subtotal (net) information, which is rendered as part of the invoice calculation below invoice line item table. Can contain placeholders, like Subtotal discounted [ProductGroup] (net).
If empty, defaults to the custom label SubTotalNetDiscounted.
Order Discount Label When showing the order discount, defines the display of the order discount information, which is rendered as part of the invoice calculation below invoice line item table. Can contain placeholders, like Discount [ProductGroup] ([OrderDiscount]).
If empty, defaults to the custom label SubTotalAEDiscount.
10 Tax Label Defines the display of the tax rate information, which is rendered as part of the invoice calculation below invoice line item table. The placeholder [TaxRate] is replaced by the actual value, like 7%.
11 Text 2 Text to be rendered below the invoice line item table, can be used, for example, to add payment terms.
Text 3 Additional text to be rendered below the Text 2 block.
Reverse Charge Text Text displayed as reverse charge notice
12 Footer Defines an area for a running footer printed on the bottom of each page of the invoice. May contain information such as the sender's address details, bank account details, and other contact information, like phone numbers, email addresses, links to web sites, etc.

Info

The template includes fields that are involved in a number of specific use cases, which are explained in their corresponding documentation.

Note

The template detail/template edit view may show the fields in a different display order, grouped by sections. If required, you can adjust the page display according to your needs (see Managing Page Layouts).

Email Contents

In addition to the fields that are printed to the PDF, the invoice template also includes texts for the email that JustOn can send to distribute the rendered PDF documents (see Distributing Invoices). These fields include:

Template Section Field Description
Email Text PDF Name Specifies the name for the generated PDF file. It can contain placeholders, the default is [InvoiceDate]_[InvoiceNo]_[AccountName].pdf.
Attach Files To Outgoing Email (checkbox) Controls whether attached files are included in any outgoing email.
Email File Types Defines which file types will be attached to emails (comma separated list of file extensions). For example, pdf,csv sends all PDF and CSV files; if empty (default), all files files are attached except for transaction table HTMLs.
Email Sender Defines an email sender address. Note that this address must be available as an organization-wide email address.
Email Subject Defines the default email subject. Can include placeholders, like Invoice: [InvoiceNo] (default).
Email Body Defines the plain text body for the email. Can include placeholders, and line breaks are considered.
Make sure that the email text includes the placeholder [InvoiceLink] (up to JustOn 2.48) or [PaymentLink] (as of JustOn 2.49) for the recipients to be able to access the invoice or payment page.
Email HTML Body Defines a rich HTML body text for the email. The editing area of this field includes an inline HTML editor.
Make sure that the email text includes the placeholder [InvoiceLink] (up to JustOn 2.48) or [PaymentLink] (as of JustOn 2.49) for the recipients to be able to access the invoice or payment page.

Note

Email Body is ignored if there is content in Email HTML Body.

Info

If you send email with non-Latin data, like the Euro symbol, Hebrew, Chinese, Japanese, Russian, etc., set your email encoding to Unicode (UTF-8). For details, see Why do PDF files or emails contain garbage characters?.

Placeholders

Placeholders are symbols for fields of Salesforce or JustOn objects (like address fields or payment data), which are to be replaced with actual values upon PDF rendering.

Basically, there are two types of placeholders:

Built-in Placeholders

JustOn provides a set of generic, built-in placeholders. These placeholders are defined in the software package. They cannot be modified nor be found in the custom setting Custom Placeholders.

The current built-in placeholders include:

Placeholder Description
[CurrentMonth]
[InvoiceLink] Provides a link to the internal payment page (up to JustOn 2.48).
[PaymentLink] Provides a link to the payment page of the JustOn Self-Service Extension (as of JustOn 2.49).
[LastMonth]
[NextMonth]
[OfLabel]
[PageCounter]
[PageLabel]
[TaxRate] Can only be used in the tax label field at the template.
[Today]

Custom Placeholders

As opposed to the built-in placeholders, custom placeholders can be modified. If you need additional placeholders for any other custom fields you may have defined, like, for example, the Account object, you can create new custom placeholders.

During the installation, JustOn creates placeholders for all standard and custom fields of JustOn objects. These placeholders are referred to as default placeholders.

Info

JustOn can add new placeholders with every software update.

JustOn implements custom placeholders using the custom setting Custom Placeholders. The following fields are available for custom placeholders:

Field Required Description
Name Specifies the name of the placeholder, which must be unique.
Decimal Places Specifies the number of decimal places to be printed when rendered as numerical value. Defaults to 2 when left blank.
Fallback if fields empty Specifies a comma-separated list of fields that must all be empty in order to trigger the fallback mechanism. This prevents mixing up of address data if, for example, only single fields of an address (like the street name) are empty. When configured properly, the fallback address is only used when all fields of the primary address are empty.
Fallback if field missing If checked, triggers the fallback mechanism if the primary field is empty.
Fallback rule Specifies the name of the placeholder that is used when the fallback mechanism is triggered by one of the conditions defined above.
Field Specifies the name of the field that is retrieved from the source object.
Render as Defines the rendering mode for the placeholder, like TEXT, DATE, MONTH, PERCENT, AMOUNT, AMOUNTISO, NUMBER, DECIMALABS, FIELDLABEL, PLAIN, LOCALAMOUNT, LOCALAMOUNTISO
Source Specifies the name of the source object from which the actual value is retrieved

Depending on the context, the following sources are available and can be used in the Source field:

Context Possible Sources Description
Invoice Invoice/Default
Account
EmailContact
RelatedInvoice
Subscription
Tenant
Can be used for the PDF and the email subject/body
Invoice Line Item InvoiceLineItem
RelatedInvoice
Can be used in the invoice table in the PDF
Dunning Dunning/Default
Account
EmailContact
Tenant
Can be used for the PDF and the email subject/body
Dunning Detail DunningDetail
RelatedInvoice
Can be used in the dunning table in the PDF
Balance Balance
RelatedInvoice
Can be used in the account statement balance table

For an overview of custom placeholders, navigate to Custom Placeholders > Manage in Setup. This displays the list of custom placeholders that you can use in templates.

To add a new custom placeholder:

  1. In Setup, open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Custom Placeholders.

  3. Click New.
  4. Specify the details as necessary.

    The mandatory information include the name, field, render as and source.

  5. Click Save.

    This creates the new custom placeholder, which can then be used immediately as [placeholdername].

Adjusting Custom Placeholder Display

You can modify the way custom placeholders are rendered.

For date placeholders, you can apply an individual format to overwrite the data format as defined with the template (see Adjusting Invoice Formatting). To this end, add the intended format as a parameter to the placeholder, like [InvoiceDate:MM/yy].

Example Date Format String
Sep 17 MMM yy
2017-10-01 yyyy-MM-dd
Fri, Sep 1, 2017 EEE, MMM d, yyyy

Info

For details about supported formats, refer to the Simple Date Format syntax in the Java Documentation.

For text placeholders, you can apply filters to modify the rendered output. The syntax is [placeholder|filter].

JustOn supports the following placeholder filters:

Filter Description Example
urlencode Encodes the rendered text into the application/x-www-form-urlencoded format, that is, replaces all non-alphanumeric characters (except for hyphen, low line and full stop) with a percent sign followed by two hex digits, and spaces with plus signs. [InvoiceLink|urlencode]
linebreak If the rendered text is not blank, inserts a line break after the rendered text. [AccountName|linebreak]
cut:x Renders only x characters of the placeholder text, where x is a natural number. [AccountName|cut:20]
no-persist "Copies" the placeholder as a variable to the invoice record, to be replaced only when the PDF is actually rendered. This allows for changes to specific values after an invoice is finalized. It guarantees that the correct value is inserted after all calculations are done, in particular, when using the [Balance] placeholder. [Balance|no-persist]

Info

You can combine filters, like [AccountName|cut:20|linebreak].

Disabling Placeholders on Invoice Line Items

Under certain circumstances, you may need to disable placeholders on invoice line items. If, for example, you retrieve the product title or description from an external system, they may contain text with square brackets that JustOn must not consider as placeholder mark but as actual brackets.

The following checkbox field on the invoice line item controls the rendering:

Field Default Value Description
Ignore Placeholders false Disables the evaluation of placeholders when finalizing invoices and rendering the PDF.

Info

You can use the ON field mechanism, Salesforce processes or other automation tools to have the Ignore Placeholders field set automatically when generating invoices and invoice line items.

CSS Rules

The layout, styling, positioning of the template building blocks is controlled using CSS rules. JustOn defines a default set of CSS rules, which are part of the Visualforce page DefaultInvoiceStructure. To view it, change to Setup and navigate to Visualforce Pages > DefaultInvoiceStructure > Preview > CSS.

According to your organization's requirements, you must adjust the default CSS using custom CSS rules. Doing so, you can modify

  • the page size of the resulting PDF document
  • margins for containers and text blocks
  • the look and feel of the invoice line item table, like border properties
  • font attributes of text elements like text size, color, etc.

The following table lists the div containers that include the commonly used building blocks as listed in PDF Contents.

div Container PDF Contents
page-header page header
page-footer footer
c1 header incl. logo
c2 billing address
c3 recipient address
sender address
c4 display type
c5 info left
info right
c6 text 1
c7 invoice line item table
c8 text 2
text 3

For information about identifying the actual CSS class to modify, refer to Accessing Template Debug Mode.

Next steps:

Customizing Templates