none
SharePoint Designer 2013 list workflow stops with message "The root activity type is invalid." RRS feed

  • Question

  • Hi,

    I have written a very simple SharePoint Designer list workflow which only writes text to the workflow log. The workflow is triggered by the new and edit event and it works well when I add or edit an item in the list. But when I try to trigger the workflow within my SharePoint Service which adds a new item in the list I ran into the workflow error "Failed on start". In the SharePoint logs I found this entry:

    RunWorkflow: Microsoft.SharePoint.SPException: <Error><CompilerError Line="1" Column="1" Text="The root activity type is invalid." /></Error>   
    Microsoft.SharePoint.Workflow.SPNoCodeXomlCompiler.LoadXomlAssembly(SPWorkflowAssociation association, SPWeb web)   
    Microsoft.SharePoint.Workflow.SPWinOeHostServices.LoadDeclarativeAssembly(SPWorkflowAssociation association, Boolean fallback)   
    Microsoft.SharePoint.Workflow.SPWinOeHostServices.CreateInstance(SPWorkflow workflow)   
    Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)   
    Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow workflow, Collection`1 events, SPWorkflowRunOptionsInternal runOptions)

    The code to add an item looks like this:

    using (SPSite oSiteCollection = new SPSite(guidSiteID, userToken))
    {
        using (SPWeb oWeb = oSiteCollection.OpenWeb(guidWebID))
        {
            oWeb.AllowUnsafeUpdates = true;
            oNewItem = ParentList.AddItem();
            ...
            oNewItem.Update();
        }
    }

    With the "userToken" I ensure that I use a specific account and not a system account what would prevent that the workflow starts. When I run the code the workflow tries to start but failed with the error above.

    When I add an item with powershell the workflow works fine.

    Does someone have an idea what I’m doing wrong?

    Wednesday, April 8, 2015 12:38 PM

Answers

  • Hi,

    According to your description, my understanding is that when you adding new items using Server Object Model, the workflow not be triggered.

    I reproduce your issue and finally I figure out by adding the code workflowmanager.dispose() after item.update() function like below:

                string url = "http://sp2013sps/sites/test";
                SPSite site = new SPSite(url);
                SPWeb web = site.OpenWeb();
                SPUserToken token = web.AllUsers[@"i:0#.w|contoso\11"].UserToken;
                Guid id=new Guid("b8776ff2-ca4f-4da0-830a-6c4ff91c943b");
                SPSite newsite = new SPSite(id, token);
                SPWeb newweb = newsite.OpenWeb();
                SPList list=newweb.Lists["list45678"];
                SPListItem newitem = list.AddItem();
                newitem["Title"] = "Test";
                newitem.Update();
                newsite.WorkflowManager.Dispose();
            

    More information:

    SharePoint object model updates not triggering workflow

    Thanks

    Best Regards


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Eric Tao Monday, April 27, 2015 5:44 AM
    • Marked as answer by Eric Tao Tuesday, April 28, 2015 2:10 PM
    Friday, April 17, 2015 9:37 AM