SharePoint development in Visual Studio requires more effort to perform task that in SharePoint Designer are made with a few clicks. To get values of a field in a list should do:
1. Add the following public property in the class of the workflow:
public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
2. Optionally, to manipulate list values could be added global variables such as:
public string title;
3. In some SharePoint activity event like the onWorkflowActivated (the initial activity which must be added in any workflow) set the properties:
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
if (workflowProperties.Item["Title"] != null)
title = workflowProperties.Item["Title"].ToString();
else
title = "Null";
}
In this way you can find the values in the list and handled within the workflow.
To get values from an InfoPath form must perform a series of additional steps. You can follow this example of Nick Swan if you need to SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007. Although an alternative could be convert the values that will be needed to SharePoint columns via the promoted properties and do as shown above.
Error: System.ArgumentNullException when referencing the WorkflowProperties
In the message list that is taking place the worklow, the displayed error is “Error Ocurred”, cancelling the workflow, unable to obtain the values of the required fields.
This usually occurs inside the OnWorkflowActivated event, because there is no property related in the WorkflowProperties
To solve this problem go to the OnWorkflowActivated properties and select the existing member in WorkflowProperties:
Click OK and ready. Values can be obtained normally.
References:
[1] WinSmarts, http://blah.winsmarts.com, 2009
[2] David Fekke, http://www.fekke.com, 2009