Firing a SharePoint Workflow by updating a list item through List Webservice

前端 未结 4 538
一生所求
一生所求 2021-02-02 14:48

I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these

相关标签:
4条回答
  • 2021-02-02 15:17

    We faced a similar issue with an Approval Workflow. To solve it, we wrote our own Event Receiver and attached it to the list. Depending on whether the item was updated or edited, we then fired the Approval Workflow.

    Hope this helps...

    0 讨论(0)
  • 2021-02-02 15:22

    I have seen the same behavior. But then you get posts like this, showing people how to create one per day to set up email reminders.

    0 讨论(0)
  • 2021-02-02 15:40

    I've encountered this issue as well and found out that once a workflow has started, it cannot be re-started automatically, no matter how you update the item. You can, however, manually start the workflow again, as many times as you like.

    0 讨论(0)
  • 2021-02-02 15:41

    Finally, we got through the support services processes at Microsoft and got a solution!

    First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something with next service pack oder next version (!)).

    But now for the problem.

    The reaseon

    Let's take a look at the CAML code from my question:

    <Method ID='1' Cmd='Update'>
      <Field Name='ID'>1</Field>
      <Field Name='myDummyPropertyField'>NewValue</Field>
    </Method>
    

    For any reason the Workflow Manager does not work with the ID, we entered in the second line. Strange, all other SharePoint commands are working with the ID, but not the Workflow Manager. The Workflow Manager works with the "fully qualified" document name. So, because we had no clue and didn't entered any fully qualified document name, the Workflow Manager defaults to the name of the current document library. And now the error message begins to make sense:

    The object specified does not belong to a list.
    

    Of course, the object (document library) does not belong to a list, it IS the list.

    The solution

    We have to add one more line to our CAML Query:

    <Field Name='FileRef'>/sites/mySite/myDocLib/myFolder/myDocument.txt</Field>
    

    The FileRef passes the fully qualified document name to the Workflow Manager, which - now totally happy - starts the workflow of the item.

    Be careful, you have to include the full absolute server path, omitting your server name (found for example in ServerRelativePath property of your SPItem).

    Full working CAML Query:

     <Method ID='1' Cmd='Update'>
        <Field Name='ID'>1</Field>
        <Field Name='FileRef'>/sites/mySite/myDocLib/myFolder/myDocument.txt</Field>
        <Field Name='myDummyPropertyField'>NewValue</Field>
      </Method>
    

    The future

    Perhaps this undocumented behaviour will be fixed in one of the upcoming service packs, perhaps not. Microsoft Support apologized and is going to release an MSDN Article on this topic. For the next month I hope this article on stackoverflow will help developers in the same situation.

    Thanks for reading!

    0 讨论(0)
提交回复
热议问题