Trick or Treat? Text to html, the wicked no-code way (Part II)

At the end of the previous post, we had this aha moment when we realized that rendering a field as rich text might not be that difficult, after all.

I’m back, after taking the time to set up a brand new demo to confirm our assumptions:



It works! As you guessed, just using a SharePoint Designer workflow to copy the content of the calculated column to a rich text field did the trick. For the record, here are the detailed steps:

  1. Create a list (I used the Tasks template here).
  2. Create a calculated column called cc, with the html formula. For the above demo I used calculated gradients (just did a copy/paste of the formula in the post).
  3. Create a column of type “Multiple lines of text” called HTMLcc, and specify that the type of text is “Enhanced rich text”.
  4. Create a one step workflow that copies the cc column to the HTMLcc column, every time an item is created or modified (screenshot below)
  5. We’re done!


The benefit of this approach is that we now have a clean field that renders our graphic – no ugly code around. I left the cc field visible for the purpose of the demo, but in production I would naturally make it a hidden field.

Although this looks great and easy, there are a couple gotchas to be aware of, if you decide to use this trick.

First, it is rather heavy: two fields and one workflow! And of course it won’t work for you if SharePoint Designer is not allowed in your environment (or you’ll need another way to copy cc to HTMLcc).

Second, it won’t help in views such as calendars, as these views don’t render rich text fields.

Third, as with any workflow action there’s a latency. The HTMLcc field will not refresh as quickly as other fields.

One last, important point: SharePoint is going to “sanitize” the html you copy to the HTMLcc field, and might decide to remove some of the content. This can actually be considered a good thing, as it addresses a security concern I reported in a previous post. On the other hand, it will block some script-based enhancements, like hover effects or countdowns.

Enjoy, and see you for next year’s trick: how to sort a list by month name. Happy Halloween!

6 thoughts on “Trick or Treat? Text to html, the wicked no-code way (Part II)

  1. Nice trick Christophe and fine for the odd column that needed the HTML rendering properly in a display but for list with a lot of Calculated Columns with HTML, as is often the case with the solutions I build, I think I’ll still to your great TextToHTML code as it is less work.

    Happy Halloween

    • That’s a good point David. This trick works best with power users who have an occasional need for the HTML Calculated Column and don’t want to be bothered with code.

      The current text to HTML script works fine, but for large scale use of this method it might be more efficient to avoid the html table and directly convert data returned from a SharePoint API (Web services for example). I’ll try to publish an example.

      • I’d certainly be interested to hear about how the convertion might be done from the API, look forward to seeing an example at some point.

  2. Hi there Christophe,
    I really like this text to html trick, but I have been asked is there anyway to show the “Health” bar for the Due date rather than % Complete?
    For instance the bar will be green until a week before the due date, amber there after and finally red the day of the due date. Any help is much appreciated.

    • Comparing dates with Today is a tricky business in SharePoint. Search my blog for “countdown” and hopefully you’ll find an example that works for you. My countdown examples rely on scripts, so the technique described in this post won’t apply (cf. last paragraph).

  3. Pingback: Transform SharePoint Data Into Actionable Business Information (BI) | The SharePoint Effect

Comments are closed.