在 EventReceiver 之后调用 SharePoint 工作流

发布于 2024-10-08 12:11:27 字数 202 浏览 9 评论 0原文

我有一个关于共享点工作流程和事件接收器的问题。我有一个正在元素上设置元数据的事件接收器。之后,我使用工作流程将项目元数据复制到列表中。不幸的是,工作流不会复制事件接收器设置的元数据。我认为因为它是在事件接收器之前执行的。是否可以更改顺序,以便工作流在事件接收器之后执行?接收者以同步方式绑定到 ItemAdded 和 ItemUpdated 事件。

感谢您的帮助! 帕特里克

i got a question regarding sharepoint workflows and event receivers. i got an event receiver that is setting metadata on an element. after that, i use a workflow to copy item metadata to a list. unfortunately the workflow does not copy the metadata set by the event receiver. i think because it is executed before the event receiver. is there a possibility to change the order, so that the workflow will execute after the event receiver? the receiver ist bound to the ItemAdded and ItemUpdated Events i a syncrounous manner.

Thank you for your help!
Patrick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听风吹 2024-10-15 12:11:27

您可以使用 SPWorkFlowAssociation 运行与 List 或 Content Type 关联的工作流。
示例(添加项目后运行工作流)

public override void ItemAdded(SPItemEventProperties properties)  
{  

    SPList parentList = properties.ListItem.ParentList;  
    SPWorkflowAssociation associationTemplate =         
      parentList.WorkflowAssociations.GetAssociationByName("Your Workflow Name",   
      new CultureInfo  
        (Convert.ToInt32(parentList.ParentWeb.RegionalSettings.LocaleId)));  
    SPSite siteCollection = properties.ListItem.ParentList.ParentWeb.Site;  
      siteCollection.WorkflowManager.StartWorkflow(properties.ListItem,  
      associationTemplate, String.Empty);  

}  

有关 SPWorkflowAssociation 的更多信息 检查以下链接

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowassociation.aspx

You can use SPWorkFlowAssociation to run workflow that associate with List or Content Type .
Example ( run workflow after adding item)

public override void ItemAdded(SPItemEventProperties properties)  
{  

    SPList parentList = properties.ListItem.ParentList;  
    SPWorkflowAssociation associationTemplate =         
      parentList.WorkflowAssociations.GetAssociationByName("Your Workflow Name",   
      new CultureInfo  
        (Convert.ToInt32(parentList.ParentWeb.RegionalSettings.LocaleId)));  
    SPSite siteCollection = properties.ListItem.ParentList.ParentWeb.Site;  
      siteCollection.WorkflowManager.StartWorkflow(properties.ListItem,  
      associationTemplate, String.Empty);  

}  

More information about SPWorkflowAssociation Check the below link

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowassociation.aspx

风轻花落早 2024-10-15 12:11:27

SPListItem:

“同步”事件(-ing 结尾如 ItemAdd*ing*)始终在工作流程之前执行。

“异步”事件(-ed 结尾,如 ItemAdd*ed*)始终在工作流程执行后执行。

因此,您必须将 Elements.xml 文件的“Synchronization”属性设置为“Synchronous”,并且工作流将始终在事件接收器之后执行。

注意:默认情况下,“添加”和“更新”事件异步运行,因此您必须在 Elements.xml 中进行更改。

SPListItem:

The "Synchronous" events (-ing ending like ItemAdd*ing*), are always executed before the workflow.

The "Asynchronous" events (-ed ending like ItemAdd*ed*), are always executed after the execution of the workflow.

So, you have to set the "Synchronization" property of the Elements.xml file equal to "Synchronous" and the workflow will always be executed after the event receiver.

ATTENTION: Events Added and Updated run asynchronously by default, so you have to do the change in the Elements.xml .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文