简体   繁体   English

顺序工作流在列表项更新时添加另一个项副本

[英]Sequential workflow adding another copy of item on update of list item

I have created a custom Sequential workflow in which i am assigning task to user like : 我创建了一个自定义的顺序工作流,在其中我向用户分配任务:

private void createTask1_MethodInvoking(object sender, EventArgs e)
    {
       SPListItem currentItem = workflowProperties.Item; 
       RequestApproveTaskId = Guid.NewGuid();
       RequestTaskProperties.Title = "";
       RequestTaskProperties.Description = "Please review the request";
       RequestTaskProperties.StartDate = DateTime.Today;            
       RequestTaskProperties.AssignedTo = userName;            
       RequestTaskProperties.EmailBody = this.EmailBody;
       RequestTaskProperties.HasCustomEmailBody = true;
       RequestTaskProperties.SendEmailNotification = true;
    }

its creating task properly and assigning to user. 它的创建任务正确并分配给用户。 No issue, working fine. 没问题,工作正常。 and I have set workflow start when adding new item to the list. 并且在将新项目添加到列表中时,我设置了工作流程开始。

Problem comes when I edit/update the List item value on which workflow is running and is in process. 当我编辑/更新正在运行并且正在处理工作流的列表项值时, 问题 就来了。 Insted of updating the existing item, It add one more item in the library with updated value which again run workflow on newly added list item. 为了更新现有项目,它在库中添加了一个具有更新值的项目,该项目再次对新添加的列表项目运行工作流。

So, My Question is how to stop this get added new item with updated value.I want to update the existing list Item and hit the OnChange() function of Sequential Workflow. 因此,我的问题是如何停止使用更新后的值添加新项。我想更新现有列表项并点击顺序工作流的OnChange()函数。 Please respond I am not getting solution on Google. 请回答,我没有在Google上找到解决方案。

ItemAdding Workflow executed every time when you add anything in your list item. 每当在列表项中添加任何内容时,都会执行ItemAdding Workflow。 Try to write you code in ItemAdded . 尝试在ItemAdded中编写代码。 Then your code runs properly as you wish. 然后,您的代码将按您希望的那样正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM