Below I am grabbing data off a Workflow with a browser enabled Infopath Form and loading a separate list.
public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
...
//Save the identifier for the workflow
workflowId = workflowProperties.WorkflowId;
// InitiationData comes from the initialization form
XmlDocument document = new XmlDocument();
document.LoadXml(workflowProperties.InitiationData);
// Get Data Off Of Init Form
XmlNamespaceManager ns = new XmlNamespaceManager(document.NameTable);
ns.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-05T20:04:17");
managerUsername = document.SelectSingleNode("/my:flowFields/my:managerUsername", ns).InnerText;
managerFullname = document.SelectSingleNode("/my:flowFields/my:managerFullname", ns).InnerText;
reviewType = document.SelectSingleNode("/my:flowFields/my:reviewType", ns).InnerText;
reviewComments = document.SelectSingleNode("/my:flowFields/my:reviewComments", ns).InnerText;
using (SPSite siteCollection = workflowProperties.Site)
{
using (SPWeb web = siteCollection.OpenWeb())
{
SPList EmployeeReviewList = (SPList)web.Lists["EmployeeReview"]; // Specific List
SPListItem EmployeeReviewItem = OptimizedAddItem(EmployeeReviewList); // Add New Item to List
EmployeeReviewItem["Review Name"] = reviewType; // Update elements of new item
EmployeeReviewItem.Update();
}
}
... }
//cf. http://blog.robgarrett.com/2009/02/25/efficient-way-to-add-a-new-item-to-a-sharepoint-list
public SPListItem OptimizedAddItem(SPList list)
{
const string EmptyQuery = "0";
SPQuery q = new SPQuery { Query = EmptyQuery };
return list.GetItems(q).Add();
}
Credit due for OptimizedAddItem(): http://blog.robgarrett.com/2009/02/25/efficient-way-to-add-a-new-item-to-a-sharepoint-list/