“I want to show HTML table with approval history in the library, but SP doesn’t let me switch the column to rich text!”
When building approval processes, I like to show the approval history directly in the item. One quick look and everyone knows what happened. But such history column must support rich text formatting. If it’s not enabled, it’ll show the html code instead of a table, making it more confusing than helpful.
Creating rich text column in SharePoint lists is easy as it’s possible directly in the column settings, but what about document libraries? You can add the Multiple lines of text column to a library, but the rich text switch is missing… How do you make the column rich text? What should you do to display the approval history in a lovely HTML table?
Create the column with an HTTP request
Even though the user interface doesn’t offer you the option anymore (it did in the past), it’s still possible to add a rich text column to a document library. As many times before, there’s an http request that’ll do it for you.
Create a Multiple lines of text column in any SharePoint library and extract its XML schema with an http request.
The output might look as the example below.
"<Field Type=\"Note\" DisplayName=\"ApprovalHistory\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Indexed=\"FALSE\" NumLines=\"6\" Sortable=\"FALSE\" ID=\"{a9b286f9-77df-4f6e-b98e-66cc49de4f8f}\" SourceID=\"{9e2a33d5-226f-4692-a651-2e18ad585ef2}\" StaticName=\"ApprovalHistory\" Name=\"ApprovalHistory\" ColName=\"ntext5\" RowOrdinal=\"0\" CustomFormatter=\"\" RichText=\"FALSE\" RestrictedMode=\"TRUE\" RichTextMode=\"Compatible\" IsolateStyles=\"FALSE\" AppendOnly=\"FALSE\" UnlimitedLengthInDocumentLibrary=\"TRUE\" Version=\"1\"/>"
Reading through all the properties, notice the RichText and RichTextMode ones. That’s the definition of a rich text column.
Change the RichText value to TRUE and RichTextMode to FullHtml.
"<Field Type=\"Note\" DisplayName=\"ApprovalHistory\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Indexed=\"FALSE\" NumLines=\"6\" Sortable=\"FALSE\" ID=\"{a9b286f9-77df-4f6e-b98e-66cc49de4f8f}\" SourceID=\"{9e2a33d5-226f-4692-a651-2e18ad585ef2}\" StaticName=\"ApprovalHistory\" Name=\"ApprovalHistory\" ColName=\"ntext5\" RowOrdinal=\"0\" CustomFormatter=\"\" RichText=\"TRUE\" RestrictedMode=\"TRUE\" RichTextMode=\"FullHtml\" IsolateStyles=\"FALSE\" AppendOnly=\"FALSE\" UnlimitedLengthInDocumentLibrary=\"TRUE\" Version=\"1\"/>"
Take the updated schema and use it to create the column in the document library.
Such column will then support rich text formatting even in document libraries.
Summary
Using rich text columns in SP document library will give you a lot of options to format the information, especially if you know a bit of html. While these columns are limited only to SharePoint lists in the interface, you can add them to document libraries too. Get the column xml schema, adjust the two properties, and create the column. Two HTTP requests to make your libraries look impressive too.
1 thought on “How to add rich text HTML column to SP document library”