SharePoint 计时器作业添加列表项,但不会触发关联的工作流 [英] SharePoint timer job add list items, but does not trigger the associated workflow
问题描述
我有一个名为Sessions"的列表,该列表有一个运行项目创建、修改的工作流.当我使用 Web 部件以及手动添加项目时,工作流会触发.我开发了一个每天运行的计时器作业,它将项目添加到会话"列表中.当计时器作业向列表中添加项目时,工作流不会触发.
I have a list called "Sessions", The list has a workflow which runs for item creation, modification. The workflow triggers when i add items using a web part as well as manually . I have developed a timer job which runs daily, which adds items to "Sessions" list. When timer job add items to the list, workflow does not trigger.
推荐答案
使用 API 创建或编辑列表项不会触发工作流.您必须使用 SPWorkflowManager
类自己触发.SPSite
的每个实例都具有该类型的属性,这是您应该使用的.
Creating or editing a list item using the API will not trigger workflows. You have to use the SPWorkflowManager
class to trigger it yourself. Every instance of SPSite
has a property of just that type, which is what you should use.
你可以这样编码:
SPSite site = foo; // Actually get your instance of SPSite by whatever is
// your favorite way to do so.
site.WorkflowManager.StartWorkflow(
item,
association,
association.AssociationData,
isAutoStart);
其中 item
是您创建/编辑的 SPListItem,association
是 SPWorkflowAssociation
将列表与实际工作流相关联,以及 isAutoStart
是一个 boolean
变量,告诉工作流管理器工作流触发器是否应该像自动启动的一样(在您的情况下,true
).
Where item
is the SPListItem which you have created/edited, association
is the instance of SPWorkflowAssociation
that correlates the list to the actual workflow, and isAutoStart
is a boolean
variable telling the workflow manager whether the workflow trigger should behave as something that was started automatically (in your case, true
).
这篇关于SharePoint 计时器作业添加列表项,但不会触发关联的工作流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!