Saturday, June 8, 2013

Rich text field in document library

You are working with document library and requirement comes in to add one rich text field in the document library. So go to document library settings and click on add column. Good. Let's go ahead.

Try to add a multi line of text and see what you get when you scroll down and look for rich text. you do not get the option.



Now this is different. Isn't this? When you go ahead and add the same multi line field in list, you get rich text setting options but in document library you do not get this.

Alright let us try something else.

Let us create a site column with multiline text and enhanced rich text.





Go back to the document library and let's add from existing site column.





So now we have the rich text multi line field in our library. so when we upload the document, we should get the RoleDescription metadata property and we should be good to go to add some rich content.

So let us upload a document and see what happens.



No luck. SharePoint converted the rich text to the normal text with multi line.

Even if you create a custom document content type and add site column to that it will not work.

Well then now we need to find out one more route.

So code comes to the rescue here.

Let's add simple code to a web part or event handler or wherever applicable in your case.
The bottom line is to use this code.



and there you go. execute this code. go back to the library, upload document or edit property of existing document and see what happens.



I hope this helps. 

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com