Please note: This blog is no longer active. My new blog is located at http://blog.timwheeler.io

Monday, October 19, 2009

SharePoint 2007, Rich Text fields and Office 2003

I had an interesting issue to deal with today. 

Issue (with SharePoint 2007 Service Pack 2):

When using Word 2003 and saving a new document to a document library in SharePoint, a validation issue exists where it ignores input of data in a required field and continually prompts the user to enter data into that field.

This occurs when the field is using Rich Text, is required and the user is saving from Word 2003 (Likely other Office 2003 products have the same issue but I have not tested this).

Steps to reproduce

1

Create a document in Word 2003, add some content.

2

Attempt to close the document, and save to a document library with a required Rich Text field.  Enter data into the Rich Text field.

3

Click OK and a validation error occurs stating "You must specify a non-blank value for [FIELD]"

Cause:

Word accesses the SharePoint server and displays a small window allowing the user to enter data for the metadata fields.  It references some html and javascript on the SharePoint server which handles saving and validation.  The javascript file (BFORM.js) doesn't save the state of the Rich Text control, and subsequent validation calls fail.

Resolution Options:

1.       Upgrade to Office 2007

2.       Don’t use Rich Text fields in the metadata schemas (Content Types)

3.       Manually fix the Javascript file (Not best practice and my invalidate your warranty - but hey, what good is that anyway)

4.       Raise the issue to Microsoft Support (and wait 2 months)

Javascript Fix Option

If you choose to fix the javascript here is what you need to do:

Locate the file at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033

*Note: The folder 1033 may be different depending on your language.

Edit this file and do the following:

1.  Add a global variable "var custom_ActiveForm;" some where towards the top of the file.

2.  Search for the function "function OWSForm" and

add the following line to the top of that function:

custom_ActiveFormName = stName;

//Customisation to fix issue with Word 2003

3. Search for the function "function RTE_SaveSelection" and add the following to the end of this function:

try
    {
        document.forms[custom_ActiveFormName][strBaseElementID].innerText = docEditor.activeElement.innerHTML;
    } catch (e) { }

 

What this does:

It makes the Html Editor save the data into the appropriate form property. 

*Please note:  I generally don't recommend this option as I cannot be sure it doesn't impact any other areas of SharePoint.  Use at your own risk.

No comments:

Post a Comment