Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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;
share|improve this question
    
please provide your code –  Prashant Lakhlani Nov 1 '12 at 6:04
    
Why do you use AllowUnsafeUpdates? –  eirikb Nov 1 '12 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. –  Torque Nov 1 '12 at 6:29

2 Answers 2

   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();
share|improve this answer

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

share|improve this answer
    
SPListItem.SystemUpdate is Not Working.. It Shows same result..:( –  Torque Nov 1 '12 at 6:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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