Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

need help launching workflow from client application (web service)

$
0
0

hi all,

I am attempting to run a visual studio sequential workflow on items in a library, but have hit a wall.   since the client object model doesn't seem to support starting workflows, I am attempting to use the web service call to "../_vti_bin/workflow.asmx" web service. 

Everything seems ok up to the point where it calls StartWorkflow(item, templateid, workflowParameters)

I get an error saying parameters can't be null.  My workflow has no init form, so im not sure what params to pass.  can someone help me out here?

here is my code:

    Private Sub LoadDataFromSite()

        Try

            Dim frm As New DateForm
            frm.ShowDialog()

            fromDate = frm.DateTimePicker1.Value.Date
            toDate = frm.DateTimePicker2.Value.Date

            Dim siteUrl As String = "http://host.dom.local/payroll/"

            Dim clientContext As New ClientOM.ClientContext(siteUrl)
            Dim oList As ClientOM.List = clientContext.Web.Lists.GetByTitle("Timesheets")
            Dim oListItem As ListItem

            Dim camlQuery As New ClientOM.CamlQuery()
            camlQuery.ViewXml = "<View/>"

            Dim collListItem As ClientOM.ListItemCollection = oList.GetItems(camlQuery)
            clientContext.Load(collListItem)
            clientContext.ExecuteQuery()

            For Each oListItem In collListItem

                Console.WriteLine("ID: {0} " & vbCrLf & "Title: {1} " & vbCrLf & "", oListItem.Id, oListItem("Title"))

                If CDate(oListItem("Timesheet_x0020_Date")).Date >= fromDate And _
                    CDate(oListItem("Timesheet_x0020_Date")).Date <= toDate Then

                    MsgBox("found a timesheet in the specified date range = " & oListItem("Timesheet_x0020_Date"))

                    'Dim ws As Workflow
                    Dim sguid As String = "{2009B982-3A49-4217-99AC-7E52C0EE44EF}"
                    Dim workflowTemplateGuid As New Guid(sguid)
                    Dim _itemURI As String = "http://host.dom.local/payroll/" & oListItem("Title")

                    Dim workflow As WSWorkflow.Workflow = New WSWorkflow.Workflow

                    workflow.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

                    workflow.StartWorkflow(_itemURI, workflowTemplateGuid, Nothing)

                End If

            Next oListItem

        Catch exs As Microsoft.SharePoint.Client.ServerException
            MsgBox("Error starting export workflow on list items.  It may not be finished yet, and you may need to export the timesheets manually." & exs.Message)
        Catch exss As Microsoft.SharePoint.Client.ClientRequestException
            MsgBox("Error starting export workflow on list items.  It may not be finished yet, and you may need to export the timesheets manually." & exss.Message)
        Catch ext As Microsoft.SharePoint.SoapServer.SoapServerException
            MsgBox("Error starting export workflow on list items.  Soap exception. " & ext.Message)
        End Try

    End Sub

so I can't pass NOTHING to the function call, so what do here?  thanks!


~george




Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>