SharePoint - workflow doesn't start - Asked By Bookworm on 28-Dec-11 08:22 AM

Hi,

I have a list which is populated by a TIMER JOB  and the created by and modified by shows system account, and of course the workflow does not start automatically.

in the timer job i did manipulating the created by and modiefied by using another username(mine), when i view the items is ok, these two field does not show system account anymore, but the workflow does not start, unless i start it manually.

any idea? thnx
Jitendra Faye replied to Bookworm on 28-Dec-11 08:31 AM
Reference from-

http://www.eggheadcafe.com/community/sharepoint/69/10397971/workflow-does-not-start-automatically.aspx


Scenario:-

     Create a new "List Workflow" through Sharepoint Designer 2010 and set the workflow setting with Start workflow automatically when an item is create or modified.


     Then save and publish the workflow. Now goto the list and create or edit the items, the attached workflow not invoke.

Reason / Solution:-

    You may be logged into the "System Account", You need to login into another non system account user.


Thanks,
Bookworm replied to Jitendra Faye on 28-Dec-11 08:35 AM
i did this, but it does not start,

there is no more  system account  because in the moment that job timer add a new item it updates also created by and modified by fields.

do you have any other idea over this?
Riley K replied to Bookworm on 28-Dec-11 08:41 AM


I am not sure with this, can you try to fire the workflow manually from code like this 

static void Main(string[] args)
    {
      using(SPSite site = new SPSite("http://intranet.contoso.com"))
      {
        using(SPWeb web = site.OpenWeb())
        {
          SPList l = web.Lists["Shared Documents"];
 
          //SPWorkflowAssociation associationTemplate = l.WorkflowAssociations[0];
          SPWorkflowAssociation associationTemplate = l.WorkflowAssociations.GetAssociationByName("Approval", System.Globalization.CultureInfo.CurrentCulture);
 
          foreach (SPListItem lt in l.Items)
          {
            site.WorkflowManager.StartWorkflow(lt, associationTemplate, associationTemplate.AssociationData);
          }
        };
      };
 
      Console.WriteLine("Done...");
      Console.ReadKey();
    }

http://social.technet.microsoft.com/Forums/en/sharepointgeneral/thread/6d1d5d51-330a-4120-9f9c-c827c8a028f9


Regards
Bookworm replied to Riley K on 28-Dec-11 09:07 AM
thnx a lot! it works awsome:-)))) that's what i was looking for.
Riley K replied to Bookworm on 28-Dec-11 09:11 AM


Welcome