Sub topic 3
Text fields: from 255 characters to rich text
This chapter assumes you can create a custom field in Object Manager and know what an API name is. Salesforce has four main text types. They differ in maximum length, formatting support, and what you can do with the field in queries and filters.
The four types
| Type | Maximum length | Lines | Formatting |
|---|---|---|---|
| Text | 255 | Single line | None |
| Text Area | 255 | Multiple lines | None |
| Text Area (Long) | 131,072 (default 32,768) | Multiple lines | None |
| Text Area (Rich) | 131,072 (default 32,768) | Multiple lines | Bold, lists, links, images |
Text is for short values such as a nickname or a code. Text Area holds the same 255 characters but keeps line breaks, so it suits short notes or a street address. Long Text Area is for comments, descriptions, and pasted content. Rich Text Area stores HTML, so users get a toolbar for bold text, lists, links, and inline images.
Choosing by length and formatting
Restrictions that matter
The longer types give up some features in exchange for space.
- A Text field can be marked unique or used as an external ID. Text Area, Long Text Area, and Rich Text Area cannot.
- Long and Rich Text Area fields cannot appear in a SOQL
WHEREclause or be used as filter criteria. You can select them, but you cannot search on them this way. - Long and Rich Text Area fields cannot be indexed or sorted, so reports and list views have little to do with them.
- A Long or Rich Text Area has a Visible Lines setting. It controls how tall the box looks on a page layout. It does not limit how much text the field stores.
- The length limit of a Rich Text Area counts the HTML markup, not just the visible text. A formatted paragraph uses more of the limit than the same words in plain text.
Common errors
- Choosing Long Text Area "just in case." You lose filtering and uniqueness, and you cannot get them back by editing the field. A field that needs to be searched should stay a Text field.
- Choosing Text for multi-line data. A single-line field is awkward for notes, and users will paste text that does not fit.
- Choosing Rich Text Area when plain text is enough. Users paste formatted content from other sources, and the stored HTML can look inconsistent.
- Setting the length too low. You can raise a Text field's length later. Lowering it risks truncating data, and Salesforce blocks the change if existing values are too long.
Pick the shortest type that fits the longest realistic value. Then check whether the field needs to be filtered, unique, or searched.
Exercise
A Case object needs a field for an agent's internal troubleshooting notes. The notes can run to several pages, and agents want bullet lists. Nobody will filter records by the notes. Which text type fits, and what limit applies to it?
Show answer
Text Area (Rich). It supports lists and formatting and holds up to 131,072 characters, which includes the HTML markup. It cannot be used in a SOQL WHERE clause, which is acceptable because nobody filters on it.