0

I had created a Custom Sequential Workflow in Visual Studio 2010 which runs when any Event is added in Calendar List. I have created a Custom Column named "Sequence". Now when I create any event in calender, Workflow Starts and makes 10 additional entries for same Data. What should I do to prevent it from creating 10 additional Entries?

enter image description here

This is How it looks when i create a new Item.

My Code is as below.

            SPWeb web = workflowProperties.Web;
            SPList Calendar = workflowProperties.List;
            web.AllowUnsafeUpdates = true;
            Random  randomNum = new Random();
            SPListItem calendarItem = Calendar.Items.Add();
            calendarItem["Sequence"] = randomNum.Next();
            calendarItem.SystemUpdate();
            web.AllowUnsafeUpdates = false;
3
  • please provide your code Nov 1, 2012 at 6:04
  • Why do you use AllowUnsafeUpdates?
    – eirikb
    Nov 1, 2012 at 6:17
  • First it was returning error that's why I used Web.AllowUnsafeUpdates but when error was gone I forget to remove it. There is no need of it. I removed it and then also code Worked. Nov 1, 2012 at 6:29

2 Answers 2

1
   I tried this and it worked.

    SPWeb web = workflowProperties.Web;
    SPList Calendar = workflowProperties.List;
    Random  randomNum = new Random();
    SPListItem calendarItem = workflowProperties.Item;
    calendarItem["Sequence"] = randomNum.Next();
    calendarItem.Update();
0

It could be that your workflow becomes recursive.
If you update the item you could try using SPListItem.SystemUpdate.

1
  • SPListItem.SystemUpdate is Not Working.. It Shows same result..:( Nov 1, 2012 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.