Wednesday, 7 September 2011

SharePoint 2010 - weirdness with custom list item edit form

I don't like SharePoint very much, but I'm forced to work with it in my software development role. A lot of what you might think of as simple functionality that could be expected out-of-the-box in a commercial content management system actually requires custom coded solution. Okay, I can do that. The trouble is though that the IT department at my company are quite strict about the provisioning of custom software. Given how buggy SharePoint Services is, I can't say I'm terribly surprised. The upshot is that any custom coded solution is discouraged in favour of some third party alternative if available. And either way, it needs to be justified. I tend not to bother with custom solutions. I often encounter weird problems with the out-of-the-box functionality though. Here's one.

I have a requirement to allow designated people to move a document from a staging document library to a permanent location once the document has been approved. After lots of mucking around I've found that the simplest way to do this is to create a custom edit form that allows input of only one item property. I've decided to use the Source URL property, since this is not actually useful in the context of the library. The plan is that there will be a workflow that kicks off whenever the document properties are changed and if there is a value for Source URL, the workflow will move the document to within that path (if legal) and then terminate. As an aside, I really wish the standard list views gave access to the file move functionality. You can't move a file from with a library, you can only send it to another location as a copy. But that's only one from an ever growing list of gripes, and not a very important one.

So anyway, I've found that this can work. However, when I (or the user) submits the custom edit form (which by the way cannot open as a dialog like the built in forms do), the result is that the document is output by the browser as an attachment. This causes a download dialog to open. I really don't want that to happen. It is confusing, to say the least. If I put the IsDialog=1 query string variable on the URL, this does not happen; however, I can't control that from actions and it shouldn't open as a dialog anyway. Also, the form does not close itself and redirect to the list as I'd expect it to. This seems to be a problem only with the custom edit forms. The default EditForm.aspx does not exhibit this strange behaviour, whether or not it is in dialog mode. I can't find anything about it on teh interwebs, so I thought I'd be the first to report it. If anything comes back, I'll be very surprised though.

No comments:

Post a comment

Flayman on LiveJournal (old)