Lack of documentation for the SharePoint 2007 object model? Decompile!

If you have been working with the object model of the new SharePoint beta I’m sure you have come across sections of the documentation labeled simply with “TODO”.  So lately I’ve been checking out the new stuff in the SPField object and I found some methods that look pretty usefull…

  • object GetFieldValue (string value)
  • string GetFieldValueAsHtml (Object value)
  • string GetFieldValueAsText (Object value)
  •  string GetFieldValueForEdit (Object value)
  •   string GetFormattedFieldValue (Object value)

 

At first sight of these methods I was like “Hey these are gonna make it easy to get the fields value in different formats.” After looking at the signatures I realized most of these methods want an object? What object do they want and why do you I need to pass anything to get a value that’s already in there? This didn’t make any sense to me. Since there is no documentation on these I just decompiled the Microsoft.Sharepoint.dll with a handy little tool call reflector. You can dl it here…

 

http://www.aisto.com/roeder/dotnet/

 

For those who don’t know what a decompiler is it basically just allows you to look at the code inside other, already compiled, applications. Its extremely useful for finding out what’s actually going on inside a program.

 

So at first, before using reflector, I just tried using the GetFieldValue method like so: string myText = myfield.GetFieldValue(“test”); to see what would happen. It just kept returning my “test” string so I figured I must be doing something wrong. So when I decompiled the method here’s what it does…

 

public virtual object GetFieldValue(string value)
{
      return value;
}

 

Whew! I was glad I didn’t spend anymore time on that! The GetFieldValue method for some strange reason just returns the string that put into it. I have no idea what the purpose of this is. After looking at the other methods mentioned above, they all perform a similar function w/ just minor differences. Pretty weird. I hope these methods actually do something usefull in the next release.

 

Anyhow I hope this info is useful to anyone working with undocumented beta features. I know it saves me a lot time!

- Mark Collins

kick it on SharePointKicks.com ?>

posted @ Wednesday, August 16, 2006 7:33 AM

Print