Articles in this section
Configure Profile Scoring Sales Process Flow - From Leads to Deals to Quotes Managing Sales Pipelines & Sales Stages Using GPT features in Vtiger Calculus Kanban View in Deals Deal Pipeline, Stages, & Lifecycle

Creating Custom Print Templates

Different functions that are available in Vtiger CRM for creating custom print templates.
B
Bindu Rekha Babu
12 May, 2025 - Updated  6 days ago

Feature Availability

Vtiger Editions: One Pilot | One Growth | One Professional | One Enterprise | One AI


Introduction

Custom Functions in the Print Templates feature allow you to insert function merge tags that go beyond basic field placeholders. These merge tags enable you to perform specific actions or transformations such as formatting dates, calculating values, or customizing text based on the parameters you define. 

You can add the following list of essential functions: 

  1. IF function
  2. NOT EMPTY Function
  3. EMPTY Function
  4. Expressions
  5. Date formats
  6. In
  7. Else if
  8. Nested custom function

Example: You want to print a message based on whether the user provided their email.

{{ IF(NOT EMPTY(email), "Email provided", "Email missing") }}

  • IF(...): Checks a condition.
  • NOT EMPTY(email): Tests if the email field has a value.
  • If the email is present, it shows Email provided.
  • If it's missing, it will show that the email is missing.


In this article, you will learn about:

  • Different custom functions
  • Using custom functions in Print Templates

Key Terminology

Field Name

Description

Function Parameters

Parameters are the values you pass into a function to control how it works.

Operators

Operators are symbols used to perform operations like comparison, logic, or math inside expressions.

Logical Expressions

A logical expression is a statement within a custom function that compares values or fields to return a true or false result.

Nested Custom function

A nested custom function is placed inside another function to perform multiple actions or evaluations in one line.



 

Adding Custom Functions in Print Templates

Let us discuss different custom functions in detail.

  • IF function: The IF function is a conventional if-else statement in programming, in which we compare one value with another.
    merge-tag : #CF|IF|param1|param2|operator|return1|return2|CF#
    • param1, param2: Parameters to compare. The values should be any of (A-Z, a-z, 0-9).
    • operator: Operator to compare parameters. The value should be of any (<,>,<=,>=,!=, ==).
    • return1: Return value, if the comparison is true.
    • return2: Return value, if the comparison is false.
  • NOT EMPTY Function: This function checks if the value is non-empty or not.
    merge-tag : #CF|NOTEMPTY|param|return1|return2|CF#
    • param: Value to check for non-emptiness.
    • return1: Value to return if value is not empty(True condition).
    • return2: Value to return if value is empty(False condition).
  • EMPTY Function: This function is the reverse of the above function(NOT EMPTY).
    • merge-tag : #CF|EMPTY|param|return1|return2|CF#
    • param: Value to check non-emptiness.
    • return1: Value to return if value is empty(True condition).
    • return2: Value to return if value is non-empty(False condition).
  • Expressions: Computes values while generating PDF by adding expressions in Print Templates.
    merge-tag : #CF|EXPRESSION|({param1}(arithmetic operator){|param2})|CF#
    • param1, param2: Parameters to compare. The values should be any of (0-9).
    • Arithmetic operator: Arithmetic operators such as +,-,/,* and %
  • Date formats: You can use Date formats in Print Templates to display dates and date-time fields in various formats according to your regional or business preferences. This allows you to format and insert date fields (such as Quote Date, Invoice Date, or Delivery Date) exactly how you need them when generating documents from the CRM.
  • Supported formats include:
    • DD.MM.YYYY (e.g., 28.04.2025) — commonly used in Europe
    • DD-MM-YYYY (e.g., 28-04-2025)
    • MM-DD-YYYY (e.g., 04-28-2025) — commonly used in the United States
    • YYYY-MM-DD (e.g., 2025-04-28) — ISO standard format
  • For example, when sending a Quote or a related document from Vtiger CRM, you can use a custom function inside the Print Template to automatically format the date fields as DD.MM.YYYY, ensuring that your documents match regional standards without manual editing.
  • In:
    • The In condition checks if a specific value exists within a list of values. It's useful when you want to act only if a field matches one of several possible values. 
    • Matches a value on multiple comma-separated values.
    • Syntax : #CF|IN|param1|param2|return1|return2|CF#
      • param1 - can be any record field or value.
      • param2 - can be multiple values separated by commas.
      • return1 when truthy, else return2 on false.
      • Consider this example : #CF|IN|{$RECORD.contactstatus}|Inactive,Cold|Not Active|{$RECORD.firstname}|CF#
      • The In condition is equivalent to Or in English and checks for multiple values. 
        • For example, if the Contact status is equal to Inactive, Cold, or Not Active, you can print the first name or add a descriptive text, such as the contact is inactive.​​​​​​​​​​​​​​​​​​​​​
  • Else If:
    • ​​​​​​​The Else If condition is used to add an alternative condition to an existing IF statement. It lets you check for multiple, different conditions in sequence.
    • Syntax: #CF|ELSEIF|param1|param2|param3|param4|operator|return1|return2|return3|CF#
      • param1 - can be any record field or value
      • param2 - will be compared against param1 based on the operator
      • param3 - can be any record field or value
      • param4 - will be compared against param3 based on the operator
      • return1 - when param1,param2 evaluation is true
      • return2 - when param3,param4 evaluation is true
      • return3 - if both evaluations are false, then return3
    • Consider example:: #CF|ELSEIF|{$RECORD.contactstatus}|Cold|{$RECORD.contactstatus}|Hot|==|send email |Call customer immediately|No action needed|CF#
    • If the contact’s status is cold, send an email; if hot, call the customer immediately. If the status is neither, take no action​​​​​​​
  • Replace
    • ​​​​​​​The replace function is used to find and replace specific text within a field value. 
    • Syntax: Custom function REPLACE (#CF|REPLACE|param1|param2|param3|CF#)
    • On selecting this custom function, you need to provide the following syntax:
      • Given a multi-select field in param 1
      • Need to give a comma in param 2
      • \n in param 3 
    • On selecting the raw merge tag, you need to give the following syntax:
      • Given a multi-select field in param 1
      • Need to give ##in parma 2
      • \n in param 3 
    • Consider this example: You can add multi-select combo box values in a print template via a custom field.  For example, you can add and print multi-select combo box values for a quote. These values are displayed vertically in columns.
    • Note: Without a proper print template and custom function, values will be displayed horizontally.
 

Nested custom function

You can use nested custom functions within Print Templates, such as the IF condition, to create more dynamic and flexible templates. This means you can place one IF condition inside another to handle multiple conditions. 

Additionally, you can include expressions or even other custom functions within the return value of an IF statement. This allows for advanced logic, such as displaying different text, formatting data, or triggering calculations based on complex conditions.

For example:

#CF| IF | contact_status| cold| ==| 

#CF| IF | state| California| ==| Call customer | Send email|CF#

| send whatsapp|CF#

Note: You can have N levels of nesting. It's supported for all custom functions.

 

Sample

You want to create a Print Template for Contact Information that dynamically displays a welcome message based on whether the contact's status is Active or Inactive.

{{ IF(status == "Active", "Welcome, valued customer!", "Please contact us to activate your account.") }}

  • IF Function:
    • Checks if the status field is equal to Active.
    • If true, the template displays Welcome, valued customer!.
    • If false (status is not Active), the template displays Please contact us to activate your account.

Follow these steps to create a Print template to display a welcome message for a Contact:

  1. Log in to the CRM account.
  2. Go to Main Menu.
  3. Go to Tools > Templates > Print Templates. The Print Template page opens.
  4. Click +Add Print Template. The New Print Template page opens.
  5. Enter or select the following information:
    1. Template name: Enter a name for the template.
    2. Module: Select the module to which the template applies.
    3. Assigned To: Assign the template to specific users or groups.
    4. Page Format: Choose the document size.
    5. Orientation:  Select Portrait(vertical) or Landscape(horizontal).
    6. Margin Left: Enter the left margin size.
    7. Margin Right: Enter the right margin size.
    8. Margin Top: Enter the top margin size.
  6. Click Next.
  7. In the template editor, add the above custom function code in the message body.
  8. Click Save.

With custom functions, you can easily adjust what your print template shows based on who the contact is.

 

References

Vtiger Print Templates

​​​​​​​
 


 
Home Privacy Policy Terms of Service Security Center Policy & Legal Center Contact Us
© Copyright 2025 Vtiger. All rights reserved.
Powered by Vtiger
Facebook Twitter Linkedin Youtube