Hola a todos,
Estoy tratando de iniciar un WorkFlow cuando se inserta un item en una lista.
Tengo el siguiente código (el cual funciona cuando lo hago desde una
aplicación):
-
public override void ItemAdded(SPItemEventProperties properties)
{
SPSite site = new SPSite("
http://misitio");
SPSecurity.RunWithElevatedPrivileges(delegate()
{
//Iniciamos el Workflow asociado a la lista.
Guid guid = item.ParentList.WorkflowAssociations[0].Id;
SPWorkflowAssociation wrkFl =
item.ParentList.WorkflowAssociations[guid];
site.WorkflowManager.StartWorkflow(item, wrkFl,
wrkFl.AssociationData, true);
item.Update();
});
}
-
Cuando lo intento hacer con el EventHandler, justo al añadir el item, lo
inicia, pero lo cancela de inmediato.
Diréis ... y porque no lo inicias automaticamente cuando se crea el item ??
Pues bién, tengo otro EventHandler que le asigna permisos al item, este
funciona perfectamente, pero si hago que el Workflow se inicie
automáticamente ... pues entonces no me funciona.
Se os ocurre alguna posible solución ??
Muchas gracias por vustra ayuda.
Saludos a todos.
Leer las respuestas