Friday, April 13, 2007

SharePoint Custom Form Doesn't Like ItemUpdating Custom Error

I have been searching for a week for a solution to this question (which I have posted all over the universe and am reposting here so that people will drop off their responses in one place, for me to check.)

Here is the situation:

In Sharepoint 2k7 have a custom list, with custom columns, and event handlers written in C#. Inside the event handler for the list event ItemUpdating, under a certain condition I want to throw a custom ErrorMessage and set the Cancel to true, so the list item will not update but send info the browser so the user knows what is up. From this same custom form I am able to throw a custom ErrorMessage from the ItemDeleting event or nearly any other event. Right now, it seems that while I can keep the item from updating, I can't display a custom message under the ItemUpdating event attached to a custom form.

You can view the frustrating C# ItemUpdating code.

If someone knows more about this and what the deal is, please, let me know.

UPDATE

I was able to talk to Microsoft Support and am still working through the issue toward resolution but a lot has been discovered. Understand that there are a number of potential failure points in this example (SharePoint 2007, SQL Server 2005, SharePoint Designer, etc.) and it takes a fairly low level of server-side event monitoring to trace where things might be going wrong. The failure in this case is very interesting. What appears (so far) to be happening is that when the custom event handler fires it does pass the custom ErrorMessage back to the SharePoint Site UI, but understand the SharePoint UI (or at least part of it, in this case) was co-created by me and SharePoint Designer when I customized the form. And since I created the custom form using Best Practices (it is a rediculously simple example that creates the failure), that narrows the culprit down to SharePoint Designer. This is what seems to be happening. Even though my custom ErrorMessage is being passed back to the SharePoint UI it gets handed to the custom Form I created with Designer which throws some error and then, in stead of showing my custom error, it shows the new Designer form error, hence the apparent loss of my custom ErrorMessage.

My best guess is that we will find out that either (1) SharePoint Designer didn't implement some interface to receive custom ErrorMessages from the custom Event code, OR (2) there is some not-yet published step in creating a custom form that binds Custom Error Messages to the custom Designer Form.

(If you want to experiment with this issue, you can download the sample custom list template I created for the MS Support team. As well you can author the custom list form with custom event completely from scratch by following these DIY instructions I wrote as well.)

I will update this entry one more time once we get the resolution on this issue.

NEARLY FINAL UPDATE

I was able to confirm with Microsoft that what I was experiencing was true. When the eventHandler passes a custom error message back to a customised SharePoint Designer 2007 form, the "designed" page throws an error and only displays that error (completely obliterating my custom error.) If you have been experiencing this, then welcome to MOSS 2007. After months of haggling, Microsoft asked me to write up a "business case justification" outlining how having this feature in a working state is critical to the adoption of their product. As a result, rather than issuing the fix inside a service pack sometime next year, they are putting it into a hotfix that should come out very soon (finally!)... don't hold your breath, however. I was told nearly six months ago that this would get "resolved" and then had to battle with two more levels of support arguing that this goofiness was "by design," and not a bug. After wearing them down they finally admitted it was in the queue for a fix and that they are looking at a hotfix now.

3 comments:

Anonymous said...

Hi Steve,

Thanks for taking the reins on this obvious oversight by MS. Any word yet from MS on this? Is a hotfix out? Was it fixed in SP1?

- Craig

Anonymous said...

Hi Steve,

I agree with Craig - thank you very much for pursuing this. I have just stumbled upon the same problem. Google brought me to your door.

Any update from MS yet?

Pete

Anonymous said...

Hotfix now available at http://support.microsoft.com/kb/949749

Pete