Plain Text Summary of Rich Text Field

Hi there!

I need to generate a plain text summary from a rich text field called “Details”. The goal is to display the plain text summary in a table (grid) view, as displaying the rich text field directly in the table breaks my styles.

First, I attempted to solve this using a formula field with a regex to remove all HTML tags, something like this

{Details}.replace(/<[^>]+>/g, '')

but turns out that knack does not support the <character in formulas.

Then, I tried to build a solution using a combination of formulas and conditional rules. I noticed that my records that have complex rich text Details are all over 2000 characters long, so I built something like this:



It became a bit messy, but worst: it doesn’t work! I think conditional rules update before the formula does, so I end up with the wrong values.

I’m going to solve this with Javascript, but I wanted to ask around in case anyone can think of a no code solution, just out of curiosity.

The requirements are not rigid. Anything can work as long as

  • Users can get the idea of the content of “Details” by looking at the table
  • table styles don’t break
  • table rows don’t become too large

Thanks!

1 Like

Hiya!
This looks incredibly interesting and the Success team would love to take a stab at helping you with this - please can I ask you to submit a ticket to support@knack.com and we can take a look at your app.

1 Like

Hi,

It’s hard to tell from your original post if this could be contributing, but I’ve noticed that formulas and conditionals can sometimes run out-of-order if your fields are not ordered from top to bottom in order of the way they reference each other.

Eg
if Field B uses the value of Field A, then Field B should be listed BELOW Field A in your list of fields (otherwise the formulas may not update in the expected order in some situations).

Since you mentioned that there’s something funky happening with the order things are running, I’m wondering whether re-ordering your fields might help you avoid using javascript?

Ahh I didn’t know the order of the fields would be relevant! I’ve already implemented the JS but I’ll keep it mind for next time. Thanks a lot!

Order of Operation

2 Likes