views:

22

answers:

1

What is the proper method for launching a workflow from within a running workflow?

We are currently using Visual Studio 2010 and the workflow is running is Sharepoint 2010. Previously this workflow functioned in Sharepoint 2007 without issue. After migrating the package to 2010, the state workflow runs normally but does not properly launch the sequential workflow. If the sequential is launched manually, it will run normally.

Here is the code we are using to call the sequential from within the state.

// Starts CAB Implementation Workflow.
SPWorkflowManager wfManager = this.workflowProperties.Site.WorkflowManager;
        SPWorkflowAssociationCollection associationCol = this.workflowProperties.List.WorkflowAssociations;
        foreach (SPWorkflowAssociation association in associationCol)
        {
            // Replace {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} with the Id of the workflow you want to invoke 
            if (association.BaseId.ToString("B").Equals("{af0775b9-8f10-468d-9201-792a4f539c03}"))
            {
                wfManager.StartWorkflow(this.workflowProperties.Item, association, "", true);
                break;
            }
        }
A: 

While creating this question we found the solution. It appears that MOSS 2007 didn't mind if the Association data was null. MOSS 2010 does not like null data and would Start the workflow but shortly after it would fail. The solution was to give an empty xml tag as the association data.

// Starts CAB Implementation Workflow.
        SPWorkflowManager wfManager = this.workflowProperties.Site.WorkflowManager;
        SPWorkflowAssociationCollection associationCol = this.workflowProperties.List.WorkflowAssociations;
        foreach (SPWorkflowAssociation association in associationCol)
        {
            // Replace {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} with the Id of the workflow you want to invoke 
            if (association.BaseId.ToString("B").Equals("{af0775b9-8f10-468d-9201-792a4f539c03}"))
            {
                wfManager.StartWorkflow(this.workflowProperties.Item, association, "<root />", true);
                break;
            }
        }

Now the sequential workflow successfully launches from the state, with no issues.

JustinB