I’ve been beating my head against a hard wall the last several months trying to get my head around working with Microsoft Office SharePoint Server (MOSS, or as my colleague Rus and I occasionally call it,“*&%@#!!”).
The latest hill I’m starting to climb is that of custom fields. They’re a very useful construct, but, as with many other things MOSS-related, the documentation’s a bit sketchy. There are a number of useful blog posts around, but most of them are very much along the lines of “Here’s how I did this one thing. It worked for me. Figure it out on your own if you need variations.” The SDK isn’t particularly helpful, and Scot Hillier’s new books on MOSS aren’t avaiable yet which really stinks.
I was getting pretty frustrated with being unable to figure out a direction to head off in, so I fell back to something that’s served me well for a couple other things: Write a unit test to poke some bit of functionality in the topic you’re trying to grok, even if it’s completely trivial.
In my case I’m looking at a field to store a collection of Guids which will identify items pulled from a database. The simple test I wrote was nothing more than constructing a collection of Guids, handing that off to the field control’s Value property, reading it back in and verifying that the contents of the returned collection matched what I’d passed in.
Woo.
OK, so that’s not rocket science, but it benefitted me in a couple ways. First, I had some success, even rudimentary. Seeing a green light in ReSharper’s unit test plugin module is a big deal when you’ve been reading skimpy dox for a couple hours and are still saying the equivalent of “Huh?” Secondly, I got a better feel for the bits and pieces I needed to interact with. Lastly, I found out that my initial approach of using generics to pass data back and forth wasn’t going to work — the Value property is overridden from the SharePoint SPField base class, so you’re not able to change its signature. Duh. My idea of a collection will work, just not a generic one.
So at least at the end of a few hours of frustration I still had something to show for it, which made me feel somewhat better.
Keep that in mind the next time you’re stuck in a rut. Give yourself a bit of success, even if it’s contrived.
1 comment:
Post a Comment