if (workflowProperties.Item.Fields.ContainsField("Custom Field") && workflowProperties.Item["Custom Field"] != null && workflowProperties.Item["Custom Field"].Equals("Some Value"))
{
// continue with rest of code
}
Tuesday, January 8, 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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment