以编程方式向列表添加SharePoint工作流

8
我们正在使用SharePoint Foundation 2010。
我们已经创建了一个工作流,用于检查任务列表的状态。
如果我们在SharePoint UI中将工作流与列表相关联,则可以正常工作。
我们想知道如何自动关联它,也许是在设置站点的功能接收器代码中?
1个回答

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;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接