Most often we are accustomed with the out-of-the-box functionalities in SharePoint to start a workflow attached with a list / library.There might be a requirement where the workflow needs to be started manually from within a programming interface i.e. a custom form which can be used for triggering workflow on specific list / library items. Dim list As SPList = web.Lists("ListName") Dim lstItem As SPListItem = list.GetItemById(itemID) Next
An example for the above requirement is provided below using VB.Net as the programming language.
'obtain an instance of SPWorkflowManager which will be used to start the workflow
Dim manager As SPWorkflowManager = site.WorkflowManager
'get all workflows associated with the list
Dim associationCol As SPWorkflowAssociationCollection = list.WorkflowAssociations
'iterate through all the workflow and lookup for the workflow to be started
For Each association As SPWorkflowAssociation In associationCol
If association.Name = "WorkflowName" Then
'get workflow association data
Dim assData As String = association.AssociationData
'start the workflow
manager.StartWorkflow(lstItem, association, assData)
Exit For
End If
Wednesday, April 21, 2010
Starting SharePoint Workflow Programatically
Posted by Rami Reddy Annapu Reddy at 11:31 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment