2010-08-12 18 views
8

Estamos utilizando SharePoint Foundation 2010.Añadir SharePoint flujo de trabajo a una lista de programación

Hemos creado un flujo de trabajo que comprueba el estado de una lista de tareas.

Si asociamos el flujo de trabajo con la lista en la IU de SharePoint, funciona bien.

Nos preguntamos cómo podríamos asociarlo automáticamente, tal vez en el código de receptor de funciones que establece el sitio?

Respuesta

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; 
Cuestiones relacionadas