在EventReceiver之后调用SharePoint工作流 [英] Invoke SharePoint Workflow after EventReceiver

查看:84
本文介绍了在EventReceiver之后调用SharePoint工作流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对共享点工作流和事件接收器有疑问.我有一个事件接收器,正在元素上设置元数据.之后,我使用工作流将项目元数据复制到列表中.不幸的是,工作流不会复制事件接收者设置的元数据.我认为是因为它是在事件接收者之前执行的.是否可以更改顺序,以便工作流将在事件接收者之后执行?接收者以同步方式绑定到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

推荐答案

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

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);  

}  

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

More information about SPWorkflowAssociation Check the below link

http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.workflow.spworkflowassociation.aspx

这篇关于在EventReceiver之后调用SharePoint工作流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆