Archive for January, 2008

Properly Checking Metadata in SharePoint Workflow

Since you want your SharePoint workflow to be as fault tolerant as possible it is always a good idea to use the following method when you are accessing fields from an SPListItem. This is especially true if they are custom fields that are deployed via a Site Column or Content Type as your workflow will receive nasty errors such as “Null Reference Exception” and “Array Out of Bounds Exception” otherwise.

if (workflowProperties.Item.Fields.ContainsField("Custom Field") && workflowProperties.Item["Custom Field"] != null && workflowProperties.Item["Custom Field"].Equals("Some Value"))
{
// continue with rest of code
}

Updating an Underlying Page Layout

Just a quick post as someone recently asked me this question and it is fairly hidden in the site.

Although changing the page layout of an existing page could be considered equivalent pulling the carpet out from under something it is possible none-the-less. Keep in mind however that if any data was displayed on the page that is not accounted for in the new page layout then that information will no longer be seen by your users. Also if you had web part zones the web parts will probably need reorganizing as they will fall into different zones.

  1. Bring up the publishing toolbar by selecting Site Actions > Edit Page
  2. From the publishing toolbar select Page > Page Settings
  3. From the page settings screen you can select a new page layout and save your changes by clicking “Ok”