FAQs: Formula field for ticket module | Zoho Desk

FAQs: Formula Field

1. What is a formula field?
 A formula field is a custom field that automatically calculates values based on other field values. It helps automate data calculations based on a predefined expression using fields, constants, operators, and functions. It updates in real time whenever the referenced field values change, eliminating the need for manual calculations.

For example, the user can automatically calculate the total refund amount using a formula expression with appropriate fields such as the ticket price and the number of tickets, along with the percentage of the amount to be refunded. In this case, the calculation assumes that only 70% of the amount will be refunded:

`{cf_ticket_price} * {no_of_tickets_booked} * 0.7`


Output:

2. How can I use values from other fields in a formula?
When creating a formula, you’ll find a Fields section that lists all available fields from the layout. To include a field in your formula, simply click on the desired field (e.g., Price or Quantity). The field’s API Name will be automatically inserted into the expression, making it easier to reference existing data without manual entry.
3. How do I add a formula field?
To add a formula field in the layout
  1. Navigate to Setup > Customization > Layouts and Fields.
  2. Under Layouts, click on the layout template that you need to add a formula field to.
  3. Select the module you want to customize and click on the specific layout template.
  4. In the Add Field, click and drag the Formula field to the desired position in the layout.
  5. Fill in the Basic Information:
    1. Provide a Label for the formula field.
    2. Choose the appropriate return type based on your calculation:
      1. Boolean: Check box on True/False
      2. Decimal: Numbers with decimal points
      3. Currency: Monetary values
      4. String: Text-based values
      5. Date: Calendar date
      6. DateTime: Date with time
    3. Start writing your expression directly in the Expression Editor.
    4. You can insert field names and operators from the available options instead of writing the entire expression manually.
    5. The Field Expression box will display all fields from the selected layout for easy reference.
    6. Use Operators:
      1. + (Add)
      2. - (Subtract)
      3. * (Multiply)
      4. / (Divide)
      5. % (Remainder)
      6. < (Less than)
      7. > (Greater than)
      8. ^ (Power)
      9. . (Dot)
    7. Click Check Syntax to verify if the formula is valid and error-free.
  6. Once validated, click Add to save the formula field to the layout.


4. What type of data can a formula field return?
A formula field can return six types of data, depending on the user's needs. These are the formula return types:
  1. Boolean: A Boolean formula returns either TRUE or FALSE.
  2. Decimal: The output of the expression and the formula field will return as a numeric value that can include decimals as 94.3.
  3. Currency: Returns a value with a currency symbol, typically representing monetary values like $444.
  4. String: Returns text values. Example: 'Hello' concatenates the string "Hello".
  5. Date: Returns a date value (without time). Example: TODAY() returns the current date as 13.02.2025.
  6. DateTime: Returns both date and time values. Example: NOW()rreturns the current date and time as 21/12/2005 06:30 AM.
5. What type of functions can I use to write an expression of my own in the formula field?
Desk provides various operators and fields for writing expressions. However, for more advanced calculations, users might need additional technical functions. These functions help automate calculations, manipulate text, handle dates and times, apply logical conditions, and convert data types.

By using these functions, you can create accurate, and efficient expressions that adapt to user's business needs without manual effort. Here’s a list of available functions for writing expressions in the formula field:
  1. Number Functions
    1. Abs: Absolute value of the number.
    2. Ceil: Smallest integer ≥ the number.
    3. Floor: Largest integer ≤ the number.
    4. Naturallog: Natural logarithm.
    5. Base10log: Base 10 logarithm.
    6. Max: Maximum value from a list.
    7. Min: Minimum value from a list.
    8. Sqrt: Square root of the number.
  2. Text Functions
    1. Len: Character count.
    2. Equals: True if strings match.
    3. EqualsIgnoreCase: True if strings match (case-insensitive).
    4. IsEmpty: True if string is empty.
    5. Find: Position of a letter.
    6. Concat: Combine strings.
    7. Contains: True if substring found.
    8. Startswith: True if string starts with substring.
    9. Endswith: True if string ends with substring.
    10. Lower: Convert to lowercase.
    11. Upper: Convert to uppercase.
    12. Trim: Remove spaces from ends.
    13. Substring: Extract part of a string.
    14. Replace: Replace occurrences of a string.
    15. ReplaceAll: Replace pattern matches.
  3. Date & Time Functions
    1. Dayofmonth: Day of the month.
    2. Hour: Hour (24-hour format).
    3. Minute: Minute of the time.
    4. Month: Month of the date.
    5. Year: Year of the date.
    6. Yr: Last two digits of the year.
    7. Weekday: Day of the week (1=Sunday).
    8. Newdatetime: Create date with time in GMT.
    9. Newdate: Create a date.
    10. Adddate: Add time (ISO8061 format).
    11. Subdate: Subtract time (ISO8061 format).
    12. Now: Current date and time.
    13. Datecomp: Time difference in minutes.
    14. Instant: Current time in ISO format.
  4. Logical Functions
    1. If: Conditional value.
    2. And: True if all conditions are true.
    3. Or: True if any condition is true.
    4. Not: Invert a boolean value.
  5. Conversion Functions
    1. Tonumber: Convert string to number.
    2. Tostring: Convert any value to string.
6. Does the field get computed automatically when the values of referenced fields change?
Yes, formula fields will automatically compute and update the output whenever the values in their referenced fields change. You don’t need to update them manually — the system recalculates the values in real time based on the formula you've set.

You can view the updated formula field under Ticket Properties > Ticket Information by opening the ticket.
7. Can I create a formula field without referring to other fields?
Yes, you can create static formulas using string as the Formula return type. For example: 'Note: MWV Bank does not accept refund.' in expression would display as: "Note: MWV Bank does not accept refund."

8. Can I use a formula field to calculate percentage?
Yes, you can use a formula field to calculate percentage. You can use the % Remainder operator in your expression. For example, agents often need to determine if a customer is eligible for a discount based on the total purchase amount.

A formula field can automatically calculate this during ticket resolution—for example, if a customer receives a 10% discount on a ₹15,000 bill, the new amount would be ₹13,500.
9. What happens if a referenced field is empty?
If a field used in the formula calculation is empty or missing, the formula output returns to 0. For example, the Amount to be refunded is calculated based on two other fields: Number of Tickets Booked and Ticket Price. If either of these fields is empty or missing, the Amount to be refunded will be calculated as 0.
10. Are formula fields visible to customers, or only to agents?
Formula fields are visible only to agents. They are designed to assist internal teams with automated calculations and data analysis within the ticketing system. Customers do not have access to these fields.
11. How do I know if my formula field expression has errors?
To check for errors in your formula field expression, simply click on the Check Syntax button after writing your expression. This will highlight any issues and help you correct them before saving the formula.

12. Are formula fields supported in all modules?
Yes, formula fields are supported in all modules. You can use them across the platform to create calculated fields based on your data.
13. Can I update formula fields manually?
No, formula fields cannot be updated manually. The output is automatically calculated based on the expression defined within them, using data from other fields. Since they are dynamically generated, any changes to their values must come from updates to the source data, not direct manual input.
14. How do I display currency values in formula fields?
To display currency values in formula fields, set the return type of the formula to Currency. This will allow the formula to display the value in the appropriate currency format.
15. Is there a character limit for formula fields?
Yes, formula fields have a character limit. The expression can contain up to 1,500 characters, which includes a maximum of 15 functions and 25 operators.
16. Can I manually type functions in a formula field?
No, you cannot type functions manually in the formula field. You must insert them using the Insert Function option.
To insert a function
  1. Choose the function you want to use from the list.
  2. Click on the Insert Function in the formula editor.
The function will be added to your expression, and you can customize its parameters as needed.