Loading

Multi-line text and rich text fields limits and restrictions

Veröffentlichungsdatum: May 7, 2026
Beschreibung

When inserting text into Salesforce multi-line text or rich text fields via the SOAP API, REST API, or Bulk API, you may receive a STRING_TOO_LONG error even when the text appears to be within the documented character limit. For example, attempting to insert exactly 4,000 characters into the CaseComment.Body field can result in a STRING_TOO_LONG error. This occurs because Salesforce enforces the character limit at the byte level for certain field types, and HTML-encoded characters or image source tags count against the limit in addition to visible characters.

Lösung

To understand why the STRING_TOO_LONG error occurs and how to work within Salesforce field limits, it is important to distinguish between multi-line text and rich text field types.

Multi-line Text Field Limits

Fields like CaseComment.Body have a documented limit of 4,000 bytes. However, the actual character limit can be less than 4,000, and varies depending on the character encoding used. The 4,000-character limit includes not just visible characters, but also any HTML encoding. For example, a single & HTML entity counts as 5 bytes but represents only 1 visible character.
The length limit in multi-line text fields is by default enforced at the character level in the Salesforce UI but at the byte level when inserting data via API. This discrepancy is the most common cause of the STRING_TOO_LONG error when inserting content that appears within limits.

Rich Text Field Limits

Rich text fields that contain images include the full image source tag (<img src="...">) in the character count. The image source tag — which can be dozens of characters long — counts against the character limit of the field. When a rich text field contains multiple images, the cumulative length of all image tags can cause STRING_TOO_LONG errors even when the visible text content is short.
See Rich Text Area Field Limitations — Salesforce Help for the full list of restrictions : https://help.salesforce.com/s/articleView?id=platform.fields_rich_text_area_limitations.htm&type=5

Nummer des Knowledge-Artikels

000382141

 
Laden
Salesforce Help | Article