I am trying to get the value of an Enhanced Rich text column and set it to another Multi line of text (Plain text) column. When I use the below line,

string richtext = li["Enhanced_x0020_Rich_x0020_Text"].ToString();

the richtext variable gets data along with the <div> & <p> tags. I tried the below way

string richtext=li.FieldValueAsText["Enhanced_x0020_Rich_x0020_Text"];

but it would throw an error

The property or field has not been initiated. It has not been requested or the request has not been executed

What is the proper way to query the data only as plain text?

4 Answers 4


Read the data as HTML and then remove tags using string manipulation or Regex

String plaintext = Regex.Replace(richTextContent, "<.*?>", string.Empty);

While loading the listItems you need to explicitly include FieldValuesAsText like below:


This will save you from the not so pretty approach of Regex as mentioned in the accepted answer.


Extending on Taran answer, if you still want values from other fields in the original form use this:

_context.Load(replies, items => items.Include(item => item.FieldValuesAsText));

You can try below mentioned code.

string richtext = li["Enhanced_x0020_Rich_x0020_Text"] != null ? li.FieldValuesAsText["Enhanced_x0020_Rich_x0020_Text"] : string.Empty;

The error message you provided is for the different thing.

It says that you are not loading the content in clientcontext properly.

You need to try context.load(li, 'Enhanced_x0020_Rich_x0020_Text'); before converting it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.