工作流程启动时在 SharePoint 中检出文档

发布于 2024-08-02 00:02:49 字数 462 浏览 5 评论 0原文

在文档库上运行工作流程时,我发现了一些问题。 在本例中,当您单击“新文档”时,它将打开 Microsoft Word。 您在文档中写入一些内容,然后将其保存到库中。 与库关联的工作流程(在本例中是本地审批工作流程)在创建列表项后开始运行。 然而问题是文档仍然处于打开状态,因此在用户关闭 Word 之前一直处于签出状态。 如果工作流执行的第一件事是设置此列表项上的一些其他字段,例如将审批状态设置为“待处理”,那么这将出错。 它出错是因为文档已签出。

我尝试让工作流程等待文档签入,但这就是我失败的地方。 我正在尝试 OnWorkflowItemChanged 活动,并在代码中检查所做的更改是否已签入文档,因此在此之后我可以继续其余的工作流程。 问题是此活动似乎没有将签入事件作为更改进行处理。 这是有道理的,因为关闭自动签入的文档实际上不会更改任何项目字段。

因此,我需要在工作流程中找到某种方法来检测签入事件,但在此之前请等待。

I've found bit of a problem when running a workflow on a document library. When you click new document it'll open up microsoft word in this example. You write some stuff into the document then save it to the library. The workflow associated to the library, in this case a home grown approval workflow with start to run now that the list item has been created. The problem however is that the document is still open and thus checked out until the user closes word. If the first thing the workflow does is to set some of the other fields on this list item such as setting an approval status to "pending" then this will error. It errors because the document is checked out.

I've tried to get the workflow to wait for the document to be checked in but this is where I'm failing. I'm trying an OnWorkflowItemChanged activity and in the code of that checking that the change made was teh document being checked in, so after this I can then continue with the rest of my workflow. The problem is that this activity doesn't seem to pick up the check in event as a change. This kind of makes sense because closing the document which automatically checks it in doesn't actually change any of the item fields.

So I need to find some way inside of my workflow to detect the check in event, but until then wait where I am.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静赏你的温柔 2024-08-09 00:02:49

解决此问题的方法是让工作流签出文档,进行任何更改,然后重新签入。

在代码中,您可以使用自定义事件处理程序来执行此操作。 查看 sharepoint SDK 或 MSDN 以获取有关对象模型的信息。

在 SharePoint Designer 中,将工作流程设置为如下所示:

选中“创建新项目时自动启动此工作流程”或“创建新项目时自动启动此工作流程”或选择这两个选项。

打下一个。

在下一页上,将条件部分留空。

在操作设置中,将您的工作流程设置为如下所示:

Check out item in <Current Item>
     then Wait for <Whatever fields you need to be set or actions you need>
     then Check in item in <Current Item> with comment: <Comment>

您也可以将其分解为步骤。 例如:

Step One - Check out current item
Step Two - Custom stuff you need to do
Step Three - Check in current item 

The fix to this is to have the workflow checkout the document, make any changes and then check it back in.

In code you would do this with a custom event handler. Check out the sharepoint SDK or MSDN for info on the object model.

In SharePoint Designer set your workflow to look like this:

Check "Automatically start this workflow when a new item is created" or "Automatically start this workflow when a new item is created" or select both options.

Hit next.

On the following page leave the conditions section blank.

In the action settings setup your workflow to look like this:

Check out item in <Current Item>
     then Wait for <Whatever fields you need to be set or actions you need>
     then Check in item in <Current Item> with comment: <Comment>

You can break this out into steps as well. For instance:

Step One - Check out current item
Step Two - Custom stuff you need to do
Step Three - Check in current item 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文