FAQs: Formula field for ticket module | Zoho Desk

FAQs: Formula Field

Formula field fundamentals

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:

Can a formula field be edited manually?
No, A formula field is read-only because its value is determined by the expression configured for it. Agents cannot replace the calculated value directly.

To change the result, update the field values used by the expression. For example, if a refund formula uses ticket price and quantity, changing either source value recalculates the refund amount automatically.
When does a formula field recalculate?
A formula field recalculates automatically whenever a referenced field value changes. No separate update or manual refresh is required.

For ticket-based calculations, the current result can be viewed in Ticket Properties under Ticket Information after opening the ticket.
What happens if a field used in a calculation has no value?
If a field referenced by a formula is empty or unavailable, the formula result is 0.

For example, consider this refund calculation:
  1. {cf_ticket_price} * {no_of_tickets_booked} * 0.7
If either the ticket price or number of tickets is empty, the calculated refund amount is 0. Ensure that all fields essential to a calculation are populated before relying on the formula output.
Are formula fields visible to customers?
No, Formula fields are intended for internal use by agents and are not available to customers. They can therefore be used for operational calculations and internal reference values within tickets.
How to 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.

How to 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.


Creating and configuring a formula field

How can a formula field be added to a layout?
  1. Navigate to Setup > Customization > Layouts and Fields.
  2. Under Layouts, open the layout template that requires the formula field.
  3. Select the relevant module and layout.
  4. In Add Field, drag the Formula field to the required location.
  5. Enter the basic configuration:
    1. Provide a clear field label.
    2. Select the return type that matches the expected result.
  6. Build the expression in the Expression Editor.
    1. Insert available fields from the field list.
    2. Insert operators or functions where required.
  7. Select Check Syntax to validate the expression.
  8. Select Add to save the formula field to the layout.
Choose the return type before finalizing the expression, since the result must match the type of value the formula is intended to produce.
How can values from other fields be inserted into a formula?
Use the Fields section in the formula editor. It lists the fields available in the selected layout.

Select the field required for the calculation, such as Price or Quantity. Its API name is inserted into the expression automatically, avoiding errors caused by manually entering a field reference.

For example, selecting ticket price and booked quantity can create an expression such as:
  1. {cf_ticket_price} * {no_of_tickets_booked}
The fields available for selection are those included in the selected layout.


Which operators are available in formula expressions?
Formula expressions support the following operators:

+ — addition
- — subtraction
* — multiplication
/ — division
% — remainder
< — less than
> — greater than
^ — power
. — dot

For example, to calculate 70% of a total amount, multiply the amount by 0.7:
  1. {cf_ticket_price} * {no_of_tickets_booked} * 0.7
The % operator returns a remainder; it is not the operator for applying a percentage rate.
How can an expression be checked before the formula field is saved?
Select Check Syntax in the formula editor after creating or updating an expression. This validates the expression and identifies issues that must be corrected before the field is saved.

Checking syntax is particularly important after combining several fields, operators, or functions. Once the expression validates successfully, select Add to create the formula field.
Is there a limit on the complexity of a formula expression?
Formula fields support detailed expressions while maintaining reliable performance. Each expression can include up to:
  1. 1,500 characters
  2. 15 functions
  3. 25 operators
These allowances accommodate a wide range of calculations, conditions, and data transformations. If a formula requires additional complexity, consider organizing the calculation into smaller, easier-to-maintain expressions using available fields.

Return types and results

What types of values can a formula field return?
A formula field supports six return types:
  1. Boolean - Returns TRUE or FALSE; suitable for condition-based results.
  2. Decimal - Returns a numeric value that may include decimal places, such as 94.3.
  3. Currency - Returns a monetary amount with the applicable currency format.
  4. String - Returns text.
  5. Date - Returns a calendar date without a time value.
  6. DateTime - Returns both a date and a time value.
Select the return type that matches the final output, rather than only the type of an individual source field.
How can a calculated amount be displayed as currency?
Set the formula field’s return type to Currency. The result is then displayed as a monetary value using the applicable currency format.

For example, a formula that calculates a refund amount can use the Currency return type:
  1. {cf_ticket_price} * {no_of_tickets_booked} * 0.7
This is preferable to using a Decimal return type when agents need to interpret the result as an amount rather than a general number.
Can a formula field return text instead of a number?
Yes. Select String as the formula field’s return type to return text.

A String formula may also contain a fixed message without referring to any other fields. For example:
  1. 'Note: MWV Bank does not accept refund.'
This displays the specified text as the formula field’s value.
Can formula fields be used for date and time calculations?
Yes. Formula fields support date and time return types and include date/time functions for creating, comparing, and adjusting date-time values.

Available date and time functions include:
  1. Dayofmonth
  2. Hour
  3. Minute
  4. Month
  5. Year
  6. Yr
  7. Weekday
  8. Newdatetime
  9. Newdate
  10. Adddate
  11. Subdate
  12. Now
  13. Datecomp
  14. Instant
Use Date when only a calendar date is required, and use DateTime when the result must include both date and time.

Functions and advanced expressions

Which functions are available for formula fields?
Formula fields provide functions for numerical calculations, text processing, date and time handling, logical conditions, and value conversion.

Number functions
  1. Abs
  2. Ceil
  3. Floor
  4. Naturallog
  5. Base10log
  6. Max
  7. Min
  8. Sqrt
Text functions
  1. Len
  2. Equals
  3. EqualsIgnoreCase
  4. IsEmpty
  5. Find
  6. Concat
  7. Contains
  8. Startswith
  9. Endswith
  10. Lower
  11. Upper
  12. Trim
  13. Substring
  14. Replace
  15. ReplaceAll
Logical functions
  1. If
  2. And
  3. Or
  4. Not
Conversion functions
  1. Tonumber
  2. Tostring
Use functions when operators alone cannot produce the intended result—for example, to evaluate a condition, standardize text, convert a value, or derive part of a date.
Can functions be typed directly into the expression editor?
No, Functions must be added through the Insert Function option in the formula editor.

To insert a function:
  1. In the formula editor, select Insert Function.
  2. Choose the required function from the available list.
  3. Add or replace the function parameters as needed in the inserted expression.
  4. Select Check Syntax before saving the formula field
Using the function selector ensures that only supported functions are inserted into the formula.
How can a formula return different values based on a condition?
Use logical functions such as If, And, Or, and Not. These functions allow the expression to evaluate conditions and return a result based on whether those conditions are met.

For example, Boolean formulas can return TRUE or FALSE for a condition, while an If function can return an appropriate value based on the condition outcome. This is useful for internal eligibility checks and other rule-based calculations.
Can text values be compared or standardized in a formula?
Yes. Text functions can compare strings, detect text, change letter case, remove leading and trailing spaces, combine text, or replace text.

For example:
  1. Use Equals when an exact text match is required.
  2. Use EqualsIgnoreCase when capitalization should not affect the comparison.
  3. Use Trim to remove spaces at the beginning and end of a value.
  4. Use Lower or Upper to standardize letter case.
  5. Use Contains, Startswith, or Endswith to evaluate whether text includes a required value.
These functions are useful when text fields need to be evaluated or normalized as part of an expression.
Info
 Read more: Formula Fields