Question

I have an asp.net web app that can insert data into a sharepoint library using sharepoint web services. How can I trigger the workflow that associates with the library after I insert data.

If I cannot trigger the workflow this way, then I have to upload a document into the Type column then it will trigger the workflow.

Was it helpful?

Solution

Call this function passing the specified parameters:

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

You'll also need

using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;

It worked for my VS app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top