Home  >   Using Vtiger   >  Creating Custom Print Templates

Creating Custom Print Templates

Different functions that are available in Vtiger CRM for creating custom print templates.
B
Bindu Rekha Babu
19 Dec, 2024 - Updated 3 months ago
Table of Contents

Introduction

You can use Custom Functions in the Print Templates feature to insert function merge tags. Function merge tags help you perform specific actions based on the parameters specified.

Adding Custom Functions in Print Templates

You can add the following list of essential functions: 

  1. IF function
  2. NOT EMPTY Function
  3. EMPTY Function
  4. Expressions
  5. In
  6. Else IF
  7. Replace
  8. Nested Custom Function

Now let’s discuss each function broadly.

  1. IF function: The if function is a conventional if-else statement in programming in which we compare one value with other.
    merge-tag : #CF|IF|param1|param2|operator|return1|return2|CF#
    1. param1, param2 : Parameters to compare. The values should be any of (A-Z, a-z, 0-9).
    2. operator : Operator to compare parameters. The value should be of any (<,>,<=,>=,!=, ==).
    3. return1 : Return value, if the comparison is true.
    4. return2 : Return value, if the comparison is false.
  2. NOT EMPTY Function: This function checks if the value is non-empty or not.
    merge-tag : #CF|NONEMPTY|param|return1|return2|CF#
    1. param : Value to check for non-emptiness.
    2. return1 : Value to return “if value” is not empty(True condition)
    3. return2 : Value to return “if value” is empty(False condition)
  3. EMPTY Function: This function is the reverse of the above function(NOT EMPTY).
    merge-tag : #CF|EMPTY|param|return1|return2|CF#
    1. param : value to check non-emptiness.
    2. return1 : Value to return “if value” if empty(True condition)
    3. return2 : Value to return “if value” is non-empty(False condition)
  4. Expressions: Computes values while generating PDF by adding expressions in Print Templates.
    merge-tag : #CF|EXPRESSION|({param1}(arithmetic operator){|param2})|CF#
    1. param1, param2: Parameters to compare. The values should be any of (0-9).
    2. arithmetic operator: Arithmetic operators such as +,-,/,* and %
  5. In:
    1. Matches a value on multiple comma-separated values
    2. Syntax : #CF|IN|param1|param2|return1|return2|CF#
    3. param1 - can be any record field or value
    4. param2 - can be multiple values separated by commas.
    5. return1 when truthy, else return2 on false.
    6. Consider this example: #CF|IN|{$RECORD.contactstatus}|Inactive,Cold|Not Active|{$RECORD.firstname}|CF#
    7. The ‘In’ condition is equivalent to ‘Or’ in English and checks for multiple values. For example, if the Contact status is equal to 'Inactive' or 'Cold' or ‘Not Active’, you can print the first name or add a descriptive text, such as the contact is inactive.
  6. Else If:
    1. Similar to 'If', with extra else if condition.
    2. Syntax : #CF|ELSEIF|param1|param2|param3|param4|operator|return1|return2|return3|CF#
    3. param1 - can be any record field or value
    4. param2 - will be compared against param1 based on the operator
    5. param3 - can be any record field or value
    6. param4 - will be compared against param3 based on the operator
    7. return1 - when param1,param2 evaluation is truthy ,
    8. return2 - when param3,param4 evaluation is truthy
    9. return3 - if both evaluations are false then return3.
    10. Consider example: #CF|ELSEIF|{$RECORD.contactstatus}|Cold|{$RECORD.contactstatus}|Hot|==|send email |Call customer immediately|No action needed|CF#
    11. Here, if the contact’s status is equal (== operator) then the action to be taken is to send an email, if the contact’s status is hot, then the action to be taken is, to call the customer immediately. If the contact’s status is neither cold nor hot, then no action is to be taken. ​​​​​​
  7. Replace:
    1. Syntax: Custom function REPLACE (#CF|REPLACE|param1|param2|param3|CF#)
      1. On selecting this custom function you need to provide the following syntax:
        1. Given multi multi-select field in param 1
        2. Need to give comma in parma 2
        3. \n in param 3 
      2. On selecting the raw merge tag you need to give the following syntax:
        1. Given the multi-select field in param 1
        2. Need to give ##in parma 2
        3. \n in param 3 
    2. 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 quotation. These values are displayed vertically in columns.
    3. Note: Without a proper print template and custom function, values will be displayed horizontally.
  8. Nested custom function
    1. You can use nested custom functions like the IF condition. You can also add another IF condition or expression in the return value. 
    2. For example:
      1. #CF| IF | contact_status| cold| ==| 
      2. #CF| IF | state| California| ==| Call customer | Send email|CF#
      3. | send whatsapp|CF#
    3. Note:  You can have N levels of nesting. It's supported for all custom functions.


 
Was this article helpful?
0  out of  3  found this helpful.
Comments 0
Be the first to comment
© Copyright 2023 Vtiger. All rights reserved.