简体   繁体   中英

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. Please respond I am not getting solution on Google.

ItemAdding Workflow executed every time when you add anything in your list item. Try to write you code in ItemAdded . Then your code runs properly as you wish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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