SharePoint工作流不会启动自动上载的文档

时间:2013-12-31 17:43:45

标签: sharepoint workflow documents

我有一项服务可以自动将文档上传到SharePoint 2013文档库。我创建了一个简单的工作流程,它在创建新项目时启动并只发送电子邮件通知;但是,工作流程仅在我手动添加文档时启动,而不是在服务上载文档时启动。如果您有任何解决方法,请提前感谢您。

2 个答案:

答案 0 :(得分:0)

如果已将工作流程附加到列表,则应自动触发工作流程。 之前我发现了一些这样的案例。请查看[here] [1]

[1]:https://sharepoint.stackexchange.com/questions/62371/workflow-not-triggered-via-custom-webpart-but-works-if-add-item-from-ui

答案 1 :(得分:0)

我必须在应用程序执行其操作后添加一些代码来启动工作流程:

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