从状态工作流中启动顺序工作流

时间:2010-07-08 12:36:44

标签: sharepoint visual-studio-2010 sharepoint-2010 sharepoint-workflow

从正在运行的工作流程中启动工作流程的正确方法是什么?

我们目前正在使用Visual Studio 2010,并且正在运行的工作流程是Sharepoint 2010.此前,此工作流程在Sharepoint 2007中运行时没有问题。将程序包迁移到2010后,状态工作流正常运行,但未正确启动顺序工作流。如果手动启动顺序,它将正常运行。

以下是我们用来从州内调用顺序的代码。

// 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;
            }
        }

1 个答案:

答案 0 :(得分:0)

在创建此问题时,我们找到了解决方案。似乎MOSS 2007并不介意协会数据是否为空。 MOSS 2010不喜欢空数据,并且会在启动工作流程后不久就会失败。解决方案是提供一个空的xml标记作为关联数据。

// 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;
            }
        }

现在,顺利工作流程从州开始成功,没有任何问题。