SharePoint工作流无法启动自动上传的文档 [英] SharePoint workflow does not start for automatically uploaded documents

查看:159
本文介绍了SharePoint工作流无法启动自动上传的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一项自动将文档上载到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.

推荐答案

在应用程序完成工作后,我必须添加一些代码来启动工作流:

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

这篇关于SharePoint工作流无法启动自动上传的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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