1

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 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?

4

1 回答 1

0

您的代码有两个问题。

1) Item URI/URL - 它应该是 Item 的 ows_EncodedAbsUrl,你可以从 Lists.asmx 中获取

2) 关联数据——不能为空。

你可以找到详细的解释。

http://sharepointbuzzer.com/2013/10/15/start-workflow-using-client-object-model/

我希望它能解决你的错误。

于 2013-10-15T06:17:02.330 回答