2010-08-12 85 views
8

我们正在使用SharePoint Foundation 2010的SharePoint工作流添加到列表编程

我们已经创建了一个检查任务列表的状态的工作流。

如果我们将工作流与SharePoint UI中的列表关联,那么它可以正常工作。

我们想知道如何自动关联它,也许在设置网站的功能接收器代码中?

回答

10
// 1. create an instance of the SPWorkflowAssociation class 
SPWorkflowAssociation workflowAssociation = 
    SPWorkflowAssociation.CreateListAssociation(workflowTemplate, associationName, taskList, historyList); 

// 2. set start options 
workflowAssociation.AllowManual = true; 
workflowAssociation.AutoStartChange = false; 
workflowAssociation.AutoStartCreate = false; 

// 3. set additional association options (if any) 
workflowAssociation.AssociationData = associationData; 

// 4. add workflow association to the list 
list.WorkflowAssociations.Add(workflowAssociation); 

// 5. enable workflow association, so it is displayed in the user interface 
workflowAssociation.Enabled = true; 
相关问题