I just learned how to register scripts properly in wordpress. Learn something new every day! loving the elimination of duplicates! 1 hr ago
  • Date
  • Thursday, January 31, 2008
  • Author
  • Corey Dutson

SharePoint 2007: What the hell, man?

So I just spent four hours of my life fight­ing with Share­Point 2007. I can’t explain all the details because my employer pays me, which in turn pays the bills and they frown upon my telling of com­pany secrets. I can, how­ever, bitch about some things that have been irri­tat­ing me over the past while. As it turns out every­thing I hate con­verged on me today.

Let the story begin!

So I’ve been charged with expand­ing on the func­tion­al­ity of a Wiki Library. For those not in the know, a Wiki Library is part of Share­Point 2007 (not WSS) and allows for some nifty fea­tures such as ver­sion view­ing, arti­cle link­ing, and… yeah that’s pretty much it. It does all of this pretty well in and of itself. Woe be upon the person (me) who tries to crack open this walnut of misery.

As it turns out, cus­tomiz­ing a Wiki Library to do any­thing isn’t just dif­fi­cult, it’s not even a chore. It’s a god­damn mis­sion of epi­cally frus­trat­ing scale. Let’s start off with some over-​all items:

  1. I needed to create custom columns, some of which looked at lists.
  2. I needed to create a con­tent type that was based off of the Wiki con­tent type.
  3. I needed to cus­tomize the Wiki library to have said con­tent type.
  4. I needed to add custom-​made web parts to the var­i­ous views of the Wiki Library (His­tory, Edit, etc)
  5. I needed all of this to work through a feature

Where to start? Lets start from the bottom of the list, because as it turns out this was the eas­i­est and where I started.

You want to edit those page lay­outs eh? Well have fun because as it turns out all of those files are system files, which means they’re on the hard-​drive of the server and there­for shared. That means you can’t mess with one with­out caus­ing a server-​wide change. The solu­tion? Copy those layout pages and rename them. Now add them to your fea­ture. I’m not going to explain how to get the fea­ture to deploy, that’s a dif­fer­ent story all together.

SharePoint Markup.jpg That’s sweet! Now how do you make any­thing use those pages? Well in terms of all the little wid­gets (Ver­sions tool, His­tory Link, Incom­ing Link) You will have to build your own ver­sions of those con­trols. Why? Well the URL of the pages that they point to are hard-​coded. Simple enough to get around, though annoy­ing as hell. Just to demon­strate, to the left is a screen shot of what SharePoints’ markup looks like just to recre­ate some of the con­trols in HTML. Seri­ously, that’s messed up. In the end each link was sur­rounded by two more tables. What the hell man?

Okay so you got all of the default pages redi­rected. What about when you edit an entry or make a new one? Those pages are tai­lored specif­i­cally for Wiki Pages (CreateWebPage.aspx) and so you’ll have to copy that one. As for redi­rect­ing it? Well you should be able to do it via an Event Receiver attached to the Fea­ture that Installs the custom con­tent type that this is all based from. please note my use of the word ’should’ because I’m still stuck there.

Let’s move onto the library for a moment. Now I have not been able to repli­cate the Wiki library prop­erly, with­out making my list type use the base­type of ‘119′. As it turns out, this comes with a whole bunch of strings attached, like having hidden name columns and a lot of red-​tape. I dare you to try and rename the “Name” column to any­thing with any sort of grace­ful code. I’ll leave that one there. For those that are won­der­ing, the default Fea­ture for Wiki Libraries is called “WebPageLib” or some­thing of that nature. Try search­ing the 12 direc­tory for the con­tent type of Wikis. To find that, go look­ing for the ctypes Fea­ture and look in there.

Cre­at­ing the fea­ture to house all of this turned out to be the eas­i­est por­tion of it all, though all of the prob­lems stemmed from it in some shape, way or form. I can’t bitch too much about the fea­ture markup itself, because all it really lacks is some func­tion­al­ity that should… well really should just be there. I’ve had to rig extra code together just to get what I wanted, but read on and I’ll explain.

I man­aged to create the con­tent type with little issues, though I had to add Remove ref­er­ences to the WikiPage con­tent type (that does exist by the way, it’s just stored in the ‘_Hidden’ group which is why you can’t touch it via the site). Adding the new con­tent type to the list tem­plate was fun too, because you have to do it via the fea­ture, since Wiki libraries do not allow you to edit the Con­tent Types of the list at all. Like I said, Wikis are sealed, and don’t like to play with the other kids.

The prob­lems really started when I cre­ated the site columns. Just a note to every­one: if you ever feel like cre­at­ing columns or con­tent types, then using them, and then trying to remove them via a fea­ture, good luck. Share­Point will not remove any­thing if it’s being used. Just a help­ful tip there. This could be fixed via some Even­tRe­ceiver code, but I won’t get into that.

Any­ways, I had a column. It was a lookup column. It wanted to look at a spe­cific list, so I gave it the list id (though to be honest this is a bad way to do it because what hap­pens when you want to deploy this fea­ture some­where else?). I deployed the column, and it worked! Then I tried to use that column in a sub-​site, which ended up fail­ing mis­er­ably. Took me for­ever to find out that you cannot spec­ify a web prop­erty in the fea­ture. webid and scopeid, yes, but noth­ing generic (refer to my listId com­ment here). The solu­tion to this was to add more custom Even­tRe­ceiver code that would do this work for me. Which worked great until I moved the fea­ture to another site.

This is where my night went bollocks.

I installed the fea­ture onto another dev-​site and acti­vated it (all through stsadm). Worked fine. Then I tried to deac­ti­vate said fea­ture, and it would just sit there. I could unin­stall it fine, but when I deac­ti­vated it the process would just hang there and I’d be forced to end it via Task Man­ager. It took me 6 ruined dev-​sites to real­ize that I was miss­ing the lists that my lookups were point­ing to. Appar­ently if you tie a lookup column to a list that doesn’t exist via code, it will crip­ple the server when you try and remove that column from any con­tent types that it was attached to. When I say crip­ple, I’m not kid­ding. stsadm.exe ran up 50 Mb of res­i­dent memory, and 100% of the CPU. The best part was that no error would be logged, it would just hang there for­ever. I admit I toyed with the idea of let­ting it run all night and going home.

I kid you not, I laughed like a madman when I finally fig­ured it out. I cannot explain why, but that’s just how it is. The lesson I learned from this really was that I shouldn’t have expected Share­Point to have any sort of intel­li­gence sit­ting behind it, and code for stu­pid­ity. Any­thing you think Share­Point should prob­a­bly just do prob­a­bly doesn’t actu­ally happen, or it hap­pens with a hope and some duct tape.

Oh and for the record, I’m still stuck on how to change the Edit/New pages properly.

Design Float Mixx Digg reddit del.icio.us StumbleUpon

Keep it clean, no spam, and thanks a bunch for any feedback you give.

*

*

*

  • Name
  • Scott C
  • Date
  • Monday, June 23, 2008
  • Website

Wel­come to the world of share­point, I actu­ally thought about blog­ging about all the issues I encounter, but then I realised I’d be blog­ging for eter­nity. It seems there are few people actu­ally trying to do devel­op­ment work with share­point, and hardly any support/documentation. It annoys me that if you go look at the mar­ket­ing for share­point theres every doc­u­ment under the sun. For sup­port its a miss mash of often incor­rect badly sorted infor­ma­tion.

  • Name
  • Timbo
  • Date
  • Friday, July 4, 2008
  • Website

Its inter­est­ing being a devel­oper and watch­ing my col­legues; so many per­son­al­i­ties. Scott you see no doc­u­men­ta­tion, I see no time to read SO MUCH doc­u­men­ta­tion. Wow! Try seach­ing “WSS SDK”, “MOSS SDK”, and “SharePoint_Training_Flyer_ITPro_and_Developer_2008-05-30″

That should keep you read­ing for the rest of the day :-)