Question

First off I want to be clear I am using the Silverlight Client Side Object Model in solution. So I cannot use objects/properties from the server object model.

What I am trying to do is get the plain text value of a field that is an enhanced rich text field. I know that I can use a RegEx to strip out the HTML, that is not what I am looking for as I would also have to deal with the character entities, etc. I am sure that I can find something pre-canned on the Internet but I would like to know if there is a native way of doing this in the CSOM.

I have tried some of the strategies in this thread (rich text to plain text), but have not managed to adapt them to the Silverlight CSOM.

Was it helpful?

Solution

Apparently it was far easier than I expected...

item.FieldValuesAsText[FIELD_NAME]

instead of item[FIELD_NAME]

So...

string businessCase = item["Business_x0020_Case"] != null ? item.FieldValuesAsText["Business_x0020_Case"] : string.Empty;

OTHER TIPS

I know the RegEx solution may not be your ideal solution, but it is indeed the least complicated. As for the character entities, etc., you can use HtmlDecode to decode any HTML character markups to plaintext.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top