我有一个服务,可以自动将文档上载到SharePoint 2013文档库。 我创建了一个简单的工作流程,它在创建新项目时启动并只发送电子邮件通知; 但是,工作流程仅在我手动添加文档时启动,而不是在服务上载文档时启动。 提前感谢您提供有关如何解决问题的任何想法。
I have a service that automatically uploads documents to a SharePoint 2013 Document Library. I created a simple workflow that starts when a new item is created and just sends an email notification; however, the workflow only starts when I manually add a document and not when it's uploaded by the service. Thank you in advance for any ideas on how to resolve it.
最满意答案
如果已将工作流程附加到列表,则应自动触发工作流程。 我之前发现了一些这样的案例。 请检查[这里] [1]
[1]: https : //sharepoint.stackexchange.com/questions/62371/workflow-not-triggered-via-custom-webpart-but-works-if-add-item-from-ui 。
I had to add some code to start a workflow after the app does its stuff:
using Microsoft.SharePoint; using Microsoft.SharePoint.Workflow; static void StartWorkflow(SPListItem listItem, SPSite spSite, string wfName) { SPList parentList = listItem.ParentList; SPWorkflowAssociationCollection associationCollection = parentList.WorkflowAssociations; foreach (SPWorkflowAssociation association in associationCollection) { if (association.Name == wfName) { association.AutoStartChange = true; association.AutoStartCreate = false; association.AssociationData = string.Empty; spSite.WorkflowManager.StartWorkflow(listItem, association, association.AssociationData); } } }更多推荐
发布评论