Sharepoint Publishing Meta Data Accessors

You've spent the past four days writing the best code in the world to interface with MOSS 2007 and its publishing features. You run it and Argghhhhh! Whats going on, all your publishing data is not there!

Chances are you have done something like this to get the properties:
VB


dim startDate as DateTime = Convert.ToDateTime(item.Properties("PublishingStartDate"));


C#

DateTime startDate = Convert.ToDateTime(item.Properties["PublishingStartDate"]);


Instead, try accessing the properties like this:
VB


dim startDate as DateTime = Convert.ToDateTime(item("PublishingStartDate"));


C#

DateTime startDate = Convert.ToDateTime(item["PublishingStartDate"]);
Now get back to that killer code and get it fixed!

No comments:

Note: only a member of this blog may post a comment.

Powered by Blogger.