如何通过仅更新列表项中的值(已批准、未批准)来触发 SharePoint 工作流?
我是 SharePoint 新手,但学得很快。
我想仅在列表项中的值更新时触发工作流,而不是每次更改该项时触发工作流。 例如,我有一个用于批准/不批准的列,我希望它成为触发器而不是项目中的其他值。 因此,如果发生其他任何更改,除非“批准”值改变,否则工作流程将不会启动。
感谢所有帮助!
谢谢,
I am new to SharePoint but I learn quick.
I want to trigger a workflow only when a value is updated in a list item, but not everytime the item is changed. For example I have a column for approve/not approve and I want that to be the trigger not the other values in the item. So if anything else is changed the workflow will not start unless the 'approval' value is.
All help is appreciated!
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以在 SharePoint Designer 中执行此操作。
希望它有所帮助。
You can do that in SharePoint Designer.
Hope it helps.
如果您希望以编程方式完成此操作...
创建一个 ItemUpdating 事件处理程序并将其附加到您的目标列表。 我将创建一个功能和功能接收器来执行附加操作。
在 ItemUpdating 事件处理程序中,您需要查看两个值:
properties.ListItem["Approval"] 这将为您提供原始值
properties.AfterProperties["Approval"] 这是更新后的值
检查两个值是否彼此不相等,以及更新后的值是否等于“approve”。 如果两者都成立,则以编程方式在列表项上启动工作流程 - 这里有一些链接可以帮助您:
http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx
编码愉快!
If you wish to accomplish this programmatically...
Create a ItemUpdating event handler and attach it to your target list. I would create a feature and feature receiver to do the attaching.
In the ItemUpdating event handler, there are two values you want to look at:
properties.ListItem["Approval"] this will give you the original value
properties.AfterProperties["Approval"] this is the updated value
Check if the two values are not equal to each other, and if the updated value is equal to "approve". If both are true, start a workflow on the list item programmatically- here are some links to help you with that:
http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx
Happy coding!
您可能需要两个工作流程、一个隐藏字段和一个“启动另一个工作流程活动”(可以在 CodePlex 上找到) )
工作流程 1 是一个辅助工作流程,设置为在项目更改时启动:
检查 Status 是否等于隐藏字段
如果是出口的话
如果没有,则启动工作流程 2 并将隐藏字段设置为状态工作流程 2 的当前值,
然后工作流程 2 就是真正的工作流程,当状态更改时,它将执行您想要的操作
You probably need two workflows, a hidden field and a "Start another workflow activity" (which can be found on CodePlex)
Workflow 1 is a helper workflow which is set to start when an item is changed:
It check if Status is equal to hidden field
If it is the exit
If not then start workflow 2 and set hidden field to current value of Status
Workflow 2 is then the real workflow which does what you want when Status is changed
首先创建一个名为“工作流程状态”的隐藏数字字段,将默认值设置为“0”
创建一个将在创建项目和修改时启动的工作流程
工作流程中的第一步是增加“工作流程状态”字段按“1”
第二步是验证该值是否为 2,这应指示第一次修改工作流.
只是为了表明状态。
工作流程状态 = 1:项目已创建
2:项目首次修改
3:项目已被第二次修改。
First create a hidden numeric field called "Workflow Status" Set the default value to "0"
Create a workflow that will initiate on both the creation of and item and on modify
The first step in the workflow is to increase the field Workflow Status by "1"
The second step is to verify is the value is 2 which should indicate the first time the workflow has been modified.
Just to indicate the status.
Workflow Status = 1: Item has been created
2: Item has been modified for the first time
3: Item has been modified a second time.
@Marius:工作流程的第一步应该是比较字段值并提供逻辑分支。 如果该值等于您想要的值,则运行工作流。 如果没有,请停止工作流程或执行其他操作。 如果收到的电子邮件有任何修改,那么您的流程就有问题。
Martin 的解决方案非常简单,但您还可以通过使用内容类型来扩展此解决方案,以允许执行其他操作的审批流程。
@Marius: The first step in the workflow should be to compare the field value and provide a logic branch. If the value equals what you want then run the worlflow. If not, stop the workflow or do something else. If the email is being received with any modification then you have got your flow wrong.
Martin's solution is very straightforward but you can also expand on this by using content types to allow for an approval process that performs another action.
看看这个帖子:
http://office.microsoft.com/en-us/sharepoint-designer-help/watch-this-run-a-workflow-when-a-specific-field-changes-HA010256419.aspx< /a>
Have a look to this post:
http://office.microsoft.com/en-us/sharepoint-designer-help/watch-this-run-a-workflow-when-a-specific-field-changes-HA010256419.aspx