[英]Sharepoint 2010 start workflow programmatically error
我有一个与内容类型相关的工作流。 我尝试从事件接收器中相同内容类型的代码中启动它,因此当更新项目时,如果存在特定条件(状态 = 准备审查),我将启动它。
//这一行确实找到了工作流关联
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"
所以基本上我有一个与内容类型“实验文档集”相关联的工作流。 当我尝试从“实验文档集”中的事件接收器启动工作流时,我收到一条错误消息,指出列表中不存在没有意义的内容类型“实验文档集”。
确保 assoc.Enabled = true。
可能为时已晚,无法提供帮助,但我刚刚了解到您不能在StartWorkflow
方法中使用String.Empty
(或null
)。
从http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx看来, assoc.AssociationData
可以用于没有任何配置参数的简单工作流。
我(还)无法对此进行测试,因为我提前了一步,可能类似于您在前两个代码示例中提到的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.