A new way of retrieving lists in SharePoint 2010

Just found of a new method within the SPListCollection object that season WSS 3.0 devs will appreciate a lot. In WSS 3.0, there’s not really a neat way to get an instance of a list that might not exist.

I usually use SPList myList = web.Lists[listName]; but it throws a null reference error if the list is not there. Looping through the SPListItemCollection object is usually how we’ll check for a list instance, but I think its a waste of resources.

In SharePoint 2010, a new method “TryGetList” is implemented to get the list and it throws a null refernce if it doesn’t find it.

using (SPWeb web = site.RootWeb)
{
 SPList myList = web.Lists.TryGetList("My List Name");
 if (myList != null)
 {
  ...
 }
}

I’m excited to get my hands dirty in SP2010, I hope incoming projects will be based on it.

Popularity: 5%

Planning for SharePoint 2010 – MOSS 2007 solution

I’m about to begin with a new SharePoint project and the management decided for it to be based on MOSS 2007. Basically its a baseline moss based portal, where future projects will be based on. And one of the critical requirements is it should support migration to SharePoint 2010 effortlessly.

Continue reading

Popularity: 4%

SharePoint 2010 – Projected Fields

SharePoint 2010 Projected Fields Projected fields are one of the new things SharePoint developers can use in their disposal with the improved list relationships and joins in SharePoint 2010. With projected fields, we don’t need to put several lookup fields from the parent list, in its basic sense, we just need to define one lookup field from the child list, and through the projected fields, we can display other fields from the child list.

Projected fields are read-only, and the most common use for it is by including extra fields from parent list to the view of child list.

Popularity: 13%

Creating Post Synchronous Event Receivers

With SharePoint 2010, “after” events or those ending with -ed such as ItemAdded, ItemDeleted, are exlusively asynchronous events. Most of the time, these would be fine and in case we needed the event to be synchoronous, then we use the -ing events such as ItemAdding or ItemDeleting. But what if we want to do some cleanup after the event has been completed? A scenario that came up to my mind is if we want to redirect the user to another page after a new item has been added or deleted to a list.
Post Synchronous events are now supported with the addition of the “Synchronization” property in the SPEventReceiverDefinition class.
SPEventReceiverDefinition myReceiver = eventReceivers.Add();
myReceiver.Synchronization = SPEventReceiverSynchronization.Sychronous;

Popularity: 11%

SharePoint 2010 – Demo VM ready for download

Microsoft has released the RTM version of its virtual machine images for evaluation environment. It contains two VHDs with pre-configured Windows Server 2008 R2 and SharePoint 2010, together with other software.

These virtual machines are Hyper-V images, so it requires your host OS to be Windows 2008 Server  R2 with the Hyper-V role enabled. In my case, I’m running Windows 7 as my host OS, so I convert the images to VMware Workstation images using WinImage Tool.

Continue reading

Popularity: 7%