通过 List Webservice 更新列表项来启动 SharePoint 工作流 [英] Firing a SharePoint Workflow by updating a list item through List Webservice

查看:42
本文介绍了通过 List Webservice 更新列表项来启动 SharePoint 工作流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的 SharePoint 顺序工作流,它应该绑定到文档库.将小工作流与文档库相关联时,我选中了这些选项

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 options

  • 允许手动执行此工作流程由经过身份验证的用户启动具有编辑项目权限.
  • 开始当一个新项目出现时的这个工作流程已创建.
  • 在以下情况下启动此工作流程更改了一个项目.

现在我将一个文档上传到这个库,工作流开始,例如发送一封邮件.它完成了,一切都很好.

Now I upload a document to this library and the workflow starts and for instance sends a mail. It completes and everything is fine.

当我在新项目上选择编辑属性"并保存更改时,工作流会再次触发.绝对符合我们的预期.

When I select Edit Properties on the new Item and save a change, the workflow is fired again. Absolutely what we expected.

即使在 Copy.asmx Web 服务的帮助下将新项目复制到库中,工作流也能正常启动.

Even when copying a new Item into the library with help of the Copy.asmx Webservice, the workflow starts normally.

但是现在我想通过 SharePoint WebService Lists.asmx 更新项目.

我的 CAML 在这里:

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

项目正在更新(时间戳也已更改,并且是一个虚拟属性),但工作流程不会再次启动.

The Item is being updated (timestamp changed and a dummy property, too) but the workflow does NOT start again.

这种行为可以在我们的开发测试系统上重现.

This behaviour is reproducable on our development and test system.

检查错误日志 (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS) 我发现了一个奇怪的错误信息:

Checking the error logs (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS) I discovered a strange error message:

09/25/2008 16:51:40.17  w3wp.exe (0x1D94)                           0x1D60  Windows SharePoint Services     General                         6875    Critical    Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver in Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below.  : The object specified does not belong to a list.

谁能证实这种行为?或任何解决方案提示?

Anybody who can confirm this behavior? Or any solution hints?

我会随时通知您有关此主题的任何进展.

I am keeping you informed of any developments on this topic.

推荐答案

最终,我们通过了 Microsoft 的支持服务流程并得到了解决方案!

首先,微软表示这是一个错误.这是一个小错误,因为有一个很好的解决方法,所以可能需要更长的时间,直到这个错误得到修复(支持技术人员说下一个服务包或下一个版本(!)).

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 (!)).

但是现在问题来了.

原因

让我们看一下我问题中的 CAML 代码:

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>

出于任何原因,工作流管理器无法使用 ID,我们在第二行中输入.奇怪的是,所有其他 SharePoint 命令都在使用 ID,而不是工作流管理器.Workflow Manager 使用完全限定"文档名称.因此,由于我们不知道也没有输入任何完全限定的文档名称,因此工作流管理器默认为当前文档库的名称.现在错误信息开始变得有意义了:

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.

解决方案

我们必须在 CAML 查询中再添加一行:

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

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

FileRef 将完全限定的文档名称传递给工作流管理器,它 - 现在非常高兴 - 启动项目的工作流.

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

请注意,您必须包含完整的绝对服务器路径,省略您的服务器名称(例如在 SPItem 的 ServerRelativePath 属性中找到).

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

完整的 CAML 查询:

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>

未来

也许这种未记录的行为将在即将推出的服务包之一中得到修复,也许不会.Microsoft 支持人员对此表示歉意,并将发布有关此主题的 MSDN 文章.在接下来的一个月里,我希望这篇关于 stackoverflow 的文章能帮助处于同样情况的开发者.

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.

感谢阅读!

这篇关于通过 List Webservice 更新列表项来启动 SharePoint 工作流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆