2010-08-12 5 views
8

Chúng tôi đang sử dụng SharePoint Foundation 2010.Thêm quy trình làm việc SharePoint vào danh sách lập trình

Chúng tôi đã tạo quy trình làm việc kiểm tra trạng thái của danh sách nhiệm vụ.

Nếu chúng tôi kết hợp quy trình làm việc với danh sách trong giao diện người dùng SharePoint, nó hoạt động tốt.

Chúng tôi đã tự hỏi làm thế nào chúng tôi có thể tự động liên kết nó, có thể trong mã nhận tính năng đặt ut trang web?

Trả lời

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;