Loading

Line Breaks Not Preserved When Copying Long Text Field to ContentNote Using Flow

Julkaisupäivä: Sep 22, 2026
Kuvaus

In Flows or Apex automations, when a Long Text Area field (e.g., Description, Notes) is copied to the Content field of a ContentNote, the resulting note appears as a single unbroken paragraph. Line breaks, paragraph spacing, or new lines present in the original text are not reflected in the note.

Root Cause

The root of this issue lies in the difference between how Long Text Area fields and the ContentNote Content field handle formatting:

  • Long Text Area fields store line breaks as plain text characters (`\r`, `\n`, or `\r\n` depending on the source).
  • ContentNote.Content is a Rich Text Area that interprets text as HTML, requiring tags like `<br/>` or `<p>` to render line breaks.

When Flow assigns plain text directly to a Rich Text field without converting the line breaks to HTML, those breaks are not rendered visually.

Ratkaisu

This article explains how to preserve line breaks in ContentNote records created via Flow, using a small Apex utility that converts plain-text line breaks into HTML before assigning the text to the Content field.

Apex Utility to Convert Line Breaks

To preserve line breaks in ContentNote records, use a small Apex utility that replaces all newline characters with `<br/>` tags before assigning the text to the Content field.

`String formatted = originalText
    .replace('\r\n', '<br/>')
    .replace('\n', '<br/>')
    .replace('\r', '<br/>');`

This code ensures that all common types of newline characters (Windows-style `\r\n`, Unix-style `\n`, and legacy Mac-style `\r`) are converted to HTML line breaks and are rendered correctly in the note content.

How to Use in Flow

  • Add an Apex Action to your Flow.
  • Pass the Long Text Area field value into the Apex method.
  • Use the formatted output to populate the ContentNote.Content field.

This method ensures the original formatting - including paragraphs and line spacing - is preserved accurately in the ContentNote.

Knowledge-artikkelin numero

004693703

 
Ladataan
Salesforce Help | Article