Sharepoint 2010以编程方式启动工作流程错误

问题描述 投票:4回答:2

我有一个与内容类型相关联的工作流程。我尝试从相同内容类型的事件接收器中的代码中启动它,因此当项目更新时,如果存在某种情况(状态=准备好进行审核),我会启动它。

//这一行确实找到了工作流程关联

var assoc = properties.Web.ContentTypes["Experiment Document Set"]
         .WorkflowAssociations.GetAssociationByName("Experiment Review Workflow",
          ultureInfo.CurrentUICulture);

//我曾尝试使用我在网上发现的这一行,但它会返回null

assoc = properties.Web.WorkflowAssociations
     .GetAssociationByName("Experiment Review Workflow",
      CultureInfo.CurrentUICulture);

下一行给出错误:

var result = properties.Web.Site.WorkflowManager
                       .StartWorkflow(properties.ListItem, assoc,string.Empty,
                                      SPWorkflowRunOptions.Synchronous);

System.ArgumentException:工作流无法启动,因为工作流与列表中不存在的内容类型相关联。在重新启动工作流之前,必须将内容类型添加到列表中。

为了检查这一点,我正在查看正在更新的列表项的内容类型,它是正确的

properties.ListItem.ContentType.Name    "Experiment Document Set"

所以基本上我有一个与内容类型“实验文档集”相关联的工作流。当我尝试从“实验文档集”中的事件接收器启动工作流程时,我收到一条错误,说明列表中不存在内容类型“实验文档集”,这是没有意义的。

c# sharepoint-2010
2个回答
0
投票

确保assoc.Enabled = true。


-1
投票

可能为时已晚,无法提供帮助,但我刚刚了解到你不能在String.Empty方法中使用null(或StartWorkflow)。

http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx看,assoc.AssociationData看起来像是一个简单的工作流程,没有任何配置参数。

我无法测试这个(还),因为我提前了一步,可能类似于你在前两个代码示例中提到的问题。

© www.soinside.com 2019 - 2024. All rights reserved.