When creating a formula field for your object, create a field in Schema Manager and enable the Is Calculated toggle. This enables Formula Builder, a tool that allows you to create expressions to calculate the value of a field (for example, calculating the net price of a line item using the formula SalesPrice * Quantity). 

Click Construct a formula here to open the Formula Builder, which allows you to create simple to complex expressions used to calculate field values for your object. All of the fields in the context object are available to use in the expression.

To create a calculated field expression

  1. Go to the Field tab and search for your desired field from the list. Click the arrow next to the field name to view and select its related child fields. The formula expression, determined by the selected object-field and/or subfield, appears on the right panel of the application.
  2. Click Insert to add it to the expression.

    The Is Pre-Computed toggle is for formula expressions that involve cross-object fields. It allows you to control how cross-object field values are handled during the evaluation of a formula expression. Formula expressions are typically evaluated at runtime, meaning their values are calculated when needed. However, when dealing with cross-object fields in a formula expression, the Is Pre-Computed toggle comes into play.

    • If the toggle is enabled, the cross-object fields used in the formula expression are computed before runtime.

    • If the toggle is disabled, the expression fetches the values of cross-object fields at runtime, just before evaluating the formula.

    Once a formula expression is defined, you cannot change the Is Pre-Computed flag. If it is initially set to FALSE, you cannot change it to TRUE later. For more information on cross-object formula expression, see Creating Cross-Object Formula Expression.

  3. Go to the Functions tab, select a function from the list, and click Insert to add it to the expression.
  4. Click any operator available below the expression window to add it to the expression.
  5. Continue building your expression.
  6. Click Clear to remove the entire expression, or manually remove it by pressing the Backspace key.
  7. Click Validate to check your formula. The application verifies the formula and displays a confirmation message if it is valid. If the formula is invalid, an error message is displayed.

  8. When you are finished, click OK. The expression you created is displayed in the Formula field.
  9. Click Save to finish or Save & Create New to create more custom fields.

Types of expression and supported functions

This table shows the types of formula expression you can define.

Types of Expression

Example

Lookup access

  • Agreement.CreatedBy.Name (CreatedBy is a lookup consisting of ID and Name only)

  • Agreement.CreatedBy.Id

  • Agreement.Account.Id

  • Agreement.Account.Name

Field access

  • Agreement.RecordType

  • Agreement.TotalAgreementValue

  • Agreement.Name

Field value comparison

  • Agreement.RecordType = "NDA"

  • Agreement.RecordType != "MSA"

Datatype equality (field comparison)

  • Agreement.CreatedDate == Agreement.ModifiedDate

  • Agreement.CreatedDate != Agreement.ModifiedDate

Mathematical operation

  • Agreement.TotalAgreementValue * 2

  • Agreement.TotalAgreementValue + 1000

  • Agreement.TotalAgreementValue - 1000

  • Agreement.TotalAgreementValue / 1000

  • Agreement.TotalAgreementValue % 2

Logical operations

  • Agreement.Status != "Request" AND Agreement.Status != "InReview" AND Agreement.Status != "InAmendment"

  • Agreement.Status != "Request" && Agreement.Status != "InReview" && Agreement.Status != "InAmendment"

  • Agreement.Status != "Request" OR Agreement.Status != "InReview"

  • Agreement.Status != "Request" || Agreement.Status != "InReview"

Conditional/Ternary operations

  • Agreement.TotalAgreementValue > 100 AND Agreement.TotalAgreementValue < 500 ? 10 : (Agreement.TotalAgreementValue > 500 && Agreement.TotalAgreementValue < 1000) ? 25 : 0

Built-in object operation

  • Mathematical comparison operation: (Agreement.EndDate.Year – DateTime.Now.Year) >= 3

  • String operation: Agreement.Account.Name.Contains("Conga")

  • String operation: !Agreement.Account.Name.Contains("Conga")

  • DateTime operation: (Agreement.EndDate.Date – Agreement.StartDate.Date).TotalDays

Relational operation

  • Agreement.TotalAgreementValue > 1000

  • Agreement.TotalAgreementValue >= 1000

  • Agreement.TotalAgreementValue < 10000

  • Agreement.TotalAgreementValue <= 10000

Functions usages

  • FN.DAY(Agreement.StartDate)

  • FN.FIND(“ABCD“, "B")

  • FN.TODAY()

Guidelines for Functions

When working with functions, use built-in C# syntax whenever applicable. For instance, consider the following expression:

FN.NOT(FN.ISBLANK(Agreement.Description))
CODE

This can be simplified using inbuilt C# syntax as:

!string.IsNullOrEmpty(Agreement.Description)
CODE