Remove Rich Text Formatting in Flows

There are times in which you want to copy text from a Rich Text Area field to a Long Text Area field. When you try to implement this in your flow you’ll find that the Long Text Area field will not just have the text, it’ll also contain the HTML tags.

Use Case:

When a Case is created with Status = New, a Follow Up Task should be created with the following field values:

1- Task: OwnerId = Case: CreatedById

2- Task: Subject = Follow Up

3- Task: WhoId = Case: ContactId

4- Task: Comments = Case: Description RichText

Please note that I created a Description RichText field on the Case object to test our case:

The flow looks something like this:

It’s a Record Triggered flow that runs After Create on the Case Object.

Decision Element:

The Decision Element is there to check if the Case Status = New. If the Case Status is New then we can create the Task record.

Create Records:

When you test this flow by creating a Case, you’ll find that all the fields were populated correctly except for the Comments field. That’s because we are trying to copy text from a Rich Text field to a Long Text field, the result is that the HTML tags like <p> and <b> are appearing as well.


Sometimes your flow needs to do more than the default elements allow, so with a little help from Apex I was able to remove the HTML tags in the Comments field. In this flow I’m calling an Apex Action to remove the rich text formatting.

What Changed?

1- I created an apex class that has an Invocable Method. This method will be called by the flow Apex Action to remove the HTML tags from the Description RichText field.

2- I created a Resource in my flow that will hold the text returned from the Apex Method.

Resource Type: Variable | API Name: plainText | Data Type: Text

3- I added the Apex Action to my flow just before the Create Records element. The Apex Action will call the Invocable Method and pass the Description RichText field as input and produce the output value in the plainText variable I created above.

4- I updated the Create Records element to assign the plainText variable that’s been returned from the Apex Action to the Comments field on the Task object.

Run the Flow

Now when you try to create a Case again to fire this flow, the HTML tags are removed successfully.

Happy Coding! :)




Salesforce Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

With Node.js: Wrap Backend SOAP Webservices In a RESTful API

Architecture of a RESTful wrapper around a SOAP Web Service

YouTube Video | DOM Crash Course -2

React for beginners …

Test The Build-In Sensor

The Evolution of Asynchronous Actions in JavaScript

Interesting Facts AboutLocksmiths

Change Detection In Angular

Create Your First React Desktop Application in Electron With Hot-Reload

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Farah Sherif Ghanem

Farah Sherif Ghanem

Salesforce Developer

More from Medium

Handling Duplicates in the Lightning Experience in Salesforce

Salesforce Platform Developer 1 Study Guide

How Does BOFC Help in Updating Salesforce Metadata?

How to mock formulas and read-only relationships in Apex tests?

Post header. Mockup of a laptop showing an interface of Salesforce, with the blue cloud, and Matheus Gonçalves logo. On the left of the laptop there are some colorful blocks and dots floating towards the screen.