CSC510231. Workflow does not start if list modified from timer job.

Description

When you perform list insert/update/delete operation from timer job it does not raise related workflows because job works under pool (system) account.

Resolution

It is required start workflows from code in the list's receivers.
public static void StartWorkFlow(SPSite site, SPList list, SPListItem item, string loginName)
{
   if (loginName.ToUpper() == "SHAREPOINT\\SYSTEM")
  {
       SPWorkflowManager workflowManager = site.WorkflowManager;
       SPWorkflowAssociationCollection workflowAssociations = list.WorkflowAssociations;
       foreach (SPWorkflowAssociation workflowAssociation in workflowAssociations)
       {
          if (workflowAssociation.AutoStartCreate || workflowAssociation.AutoStartChange)
          {
              workflowManager.StartWorkflow(item, workflowAssociation, workflowAssociation.AssociationData);
           }
          }
       }
}

Links

SPWorkflowManager Class
Решение задачи. Задача таймера.
Решение задачи. Задача таймера, продолжение.
Решение задачи. Задача таймера, почти конец.
Решение задач. Задача таймера, совсем конец.

Last edited Jan 24, 2014 at 1:17 PM by dvd73, version 6

Comments

No comments yet.