Atulya
Atulya

Reputation: 160

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.

Upvotes: 0

Views: 855

Answers (1)

Jay Doshi
Jay Doshi

Reputation: 340

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.

Upvotes: 1

Related Questions