The Perfect Storm (InfoPath, Versioning and Rich Text)
Update April 1, 2015
Microsoft apparently issued a hotfix for this issue in June of 2013.
If this is your problem – then get the hotfix here:
I have a SharePoint list with a custom InfoPath list form, versioning turned on (3 major versions only), and 3 multi-line text fields that are defined as “Enhanced rich text”. The combination of these variables created a perfect storm for me the other day. Change any one of the three conditions, the error doesn’t exist, but it’s too late, you’re already stuck. Let me explain.
About 48 versions later of a particular list item (mind you, I am keeping only 3 versions), when I try to open the form, I get the following error:
“The “BrowserFormWebPart” Web Part appears to be causing a problem. An XML error has occurred.”
I can neither open the form to display the item nor open the form to edit the item.
When I look this up on Google, there is not much to see; one is a Technet forum post, and one is a blog post. (This blog post is gone now.)
The essence of both of these posts is that when you have an InfoPath form, multi-line rich text fields and versioning turned on, the fields that are the rich text fields will start to accumulate extra data. This extra data will eventually make it such that you cannot open the form.
Here’s the exact problem
When an Enhanced rich text field is stored in the SharePoint database table field, it is stored wrapped in tags of the form
<div class="ExternalClassxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> <html> YOUR CONTENT IS HERE WHICH MAY ALSO HAVE HTML IN IT </html> </div>
This is normal behavior. However,
If you customize the form with InfoPath AND you have versioning turned on, the fun begins. At that point, each time you edit the item, another set of
tags is wrapped around the previous version of the content in the database field – that includes the wrapper(s) that were already there from the previous versions. Every. Time. It doesn’t matter how many versions you have chosen to keep. It just keeps wrapping these tags around the previous content of your field. For my item, 48 versions was enough to make the XmlLoader give up.
My contribution to the party is this:
- You have to have a multi-line text field that is an “Enhanced rich text” field. (Which, BTW, is the DEFAULT setting for a multi-line field, so beware.) If you use a simple “Rich text” multi-line field, the problem does not get created. You can change your “Enhanced rich text” fields to simple “Rich text” to avoid the problem with future items, but it won’t
solve the problem if you currently have the problem.
- You have to have an InfoPath form. In my case, it is a customized list form. If you are using the default SharePoint list forms only one set of <div><html> tags is ever wrapped around the content, so the problem does not get created. After you encounter the problem, if you switch the list back to using the default SharePoint forms, the problem goes away – meaning that you will be able to open and edit the item that was giving you the problem.
- You have to have versioning turned on. It does not matter how many versions you are keeping. If you do not have versioning turned on only one set of <div><html> tags is ever wrapped around the content, so the problem does not get created. Turning off versioning will not solve the problem if you currently have the problem, but it will keep the problem from happening to other items in the list. Removing some of the old items from the version history does not solve the problem.
Once the database field is overrun with the data, you only have two options.
- Switch back to the default SharePoint .aspx form. The SharePoint form seems to ignore all the extra data. In my case, (and I suspect in most everyone’s case) this is NOT AN OPTION.
- Modify the data in the database field to clean out the extra tags. The only supported ways of doing that is to make a call to Microsoft, or do what we did and write a PowerShell script to clean out the field.
You are only going to be able to get two out of the three features without encountering the error, so pick your two most important and go with those.
- Use only simple “Rich text” multi-line fields unless you really have a need to be able to include tables, hyperlinks and images in your multi-line text fields. If you do, you can have InfoPath forms and versioning.
- Use only SharePoint forms. If you do, you can have “Enhanced rich text” multi-line fields and versioning.
- Leave versioning off. If you do, you can have InfoPath forms and “Enhanced rich text” multi-line fields.