Using Flow to Convert Rich Text to Plain Text

Using Flow to Convert Rich Text to Plain Text

Rich text includes formatting like bold, italics, colors, and hyperlinks, enhancing visual presentation. In contrast, plain text consists of unformatted characters, maintaining simplicity and universal readability. In certain scenarios, converting rich text to plain text might be necessary. This conversion simplifies the content, ensuring compatibility with systems that only support plain text and streamlining data processing.

It is possible to use stripHtmlTags method in Apex to convert rich text to plain text. This method removes the HTML tags from a string and returns plain text. In this post, you can find an invocable action that converts rich text to plain text.

How to Use the Component

1- Install the component using the installation links below.

2- Add a new action to your flow and search for Convert to Plain Text. This is the name of the action that you installed.

Invocable Action to Convert Rich Text to Plain Text

3- As an input, provide the rich text value that you want to convert.

Output of this action is the plain text that you wanted.

Example

Let's assume that we have a rich text field on the Case object. Here is a screen flow that converts its value to plain text.

1- Create an input record variable for the Case. Then add the Convert to Plain Text action and provide the rich text field as the input.

Convert to Plain Text Action

2- Add an Update Records element to update the description of the case record.

Update Case Description

3- Add a Screen element with two display text components to see the input and output side by side.

Screen Element to Display the Output

At the end, your simple flow should look like this.

End of the Flow

As you can see, output of the action is a plain text.

Screen That Shows The Result of Convert Rich Text to Plain Text
Result of Action to Convert Rich Text to Plain Text

Considerations

  • This action removes all of the HTML tags. This means that you will lose the line breaks as well.
  • This action removes white-space characters as well.
  • The stripHtmlTags function does not recursively strip tags; therefore, tags may still exist in the returned string.
  • The stripHtmlTags function may be deprecated in the future.

Installation Links

Use this link to install in production or developer edition environments.

Use this link to install in sandbox environments.

4 Comments

  1. Thanks for sharing this. But when I tried the link for sandbox I see error:
    Package Not Found The requested package doesn't yet exist or has been deleted. If this is a recently created package version, please try again in a few minutes or contact the package publisher.

Leave a Reply

Your email address will not be published.


*