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

标签 c# sharepoint-2010

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

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

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: Workflow failed to start because the workflow is associated with a content type that does not exist in a list. Before re-starting the workflow, the content type must be added to the list.

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

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

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

最佳答案

确保 assoc.Enabled = true。

关于c# - Sharepoint 2010 以编程方式启动工作流错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4565332/

相关文章:

c# - 旋转和平移对象

c# - KeyNotFoundException 与在线数据库

visual-studio-2010 - 将列表模板 STP 文件导入到 Visual Studio 2010

sharepoint - 确定 SPQuery 返回的项目总数

c# - 如何为 SPItem 授予 SPGroup 权限?

javascript - ASP.NET DataGrid ClientID 值返回 null

c# - 如何将 C 数组映射和编码为 C# 代码

c# - 事件目录是否防止不在域中的客户端进行修改?

sharepoint-2010 - Sys.InvalideOperationsExcetion

sharepoint - 在 SharePoint 2010 中获取随机用户配置文件