Table of Contents


Formula Fields

A Formula field computes its value at read time from other fields on the same record. Formulas are read-only.


Create a Formula Field

POST /api/3.0/entity/EntityField
Authorization: Bearer <token>
Content-Type: application/json
Accept: application/json

{
  "EntityId": "7NS0000000000A50001",
  "Name": "DaysActive",
  "Label": "Days Active",
  "FieldTypeId": "7NY00000000000m0000",
  "RelatedToFieldId": "7NY00000000000b0000",
  "DefaultValue": "TODAY() - StartDate__c",
  "DecimalPlaces": 0
}

Payload Reference

PropertyNotes
FieldTypeId7NY00000000000m0000 (Formula).
DefaultValueThe formula expression. Reference other fields by their API name (with __c suffix for custom fields).
RelatedToFieldIdRequired. The formula's return type, expressed as a FieldType ID (from Field Type Reference) — not a reference to another field.
DecimalPlacesFor a numeric return type, sets the precision (for example, DecimalPlaces = 2 when returning Currency). Length is not accepted on a Formula field.

Return Type → RelatedToFieldId

Set RelatedToFieldId to the FieldType ID of the type your formula evaluates to:

Return typeRelatedToFieldId
Text7NY0000000000000000
Number7NY00000000000b0000
Currency7NY00000000000a0000
Percent7NY00000000000c0000
Date7NY0000000000070000
DateTime7NY0000000000020000
Checkbox (boolean)7NY0000000000050000

If the expression does not evaluate to the declared return type, the API returns an HTTP 406 with the parser's error message identifying the mismatch.


Behavior

  • Formula fields are read-only. Attempting to write to one on a record CRUD call returns an error.
  • IsRequired is not allowed on Formula fields.
  • IsUnique is not allowed on Formula fields.
  • Referencing a Formula's field name inside another Formula is allowed; cyclic references are rejected at save time.
  • Changing a Formula's expression is done via PATCH on DefaultValue. Changing the return type (RelatedToFieldId) is generally rejected if any other field depends on the current type.

Constraints on Length Changes

If a Text field is used inside a formula, that field's Length cannot be increased above 4,000 — the platform blocks the update to protect the formula's validity. Remove the formula's reference first, resize the Text field, then re-add the formula.


Formula Grammar and Function Reference

Formula syntax, operators, and the full function library (date functions, string functions, conditionals, aggregations) are documented separately. See Configuring Magentrix Entity Formula Fields for the complete grammar and function reference.


Common Examples

PurposeReturn typeExpression
Days since a dateNumberTODAY() - StartDate__c
Full name concatenationTextFirstName + " " + LastName
Discounted totalCurrencyAmount__c * (1 - DiscountPct__c / 100)
Is overdueCheckboxDueDate__c < TODAY() && !IsPaid__c
Priority labelTextIF(Amount__c > 100000, "Enterprise", IF(Amount__c > 10000, "Mid", "SMB"))

Field names in expressions are case-sensitive. Custom-field references must include the __c suffix.


<< Rollup Summary Fields | Entity Management API Overview

Last updated on 7/28/2026

Attachments