Do you want to create new calendar recurring event from SharePoint workflow?

You can easily create simple calendar event (which doesn’t have recurring properties/values), some days before I was trying to create new recurring event from SPD workflow using “Create Item” action, and found that we can’t create recurring event from SPD workflows because when we’re trying to add new calendar list item from ‘Create Item’ OOB workflow action, at that point we can’t assign the recurring rules values to ‘Recurrence’ column and there is not any available way to pass recurrence rule xml values.


SPD_WF

 
I found an interesting article which creates new calendar event with recurring parameters programatically(http://msdn.microsoft.com/en-us/library/ms434156.aspx). But I was looking to create calendar events from SPD workflows and I decided to create workflow custom action to insert new recurring events. If you don’t know how to create custom action for SPD workflows then look at here (http://msdn.microsoft.com/en-us/office365trainingcourse_lab_3_2_topic3#_Toc290553044), this is very simple and easier solution to create custom custom actions from VS. You just have to make following changes,
  1. Add new class file to the solution for recurring event action (I created as “CreateCalendarRecurrenceEvent.cs”)
  2. Open ‘Element.xml’ file and add following action
  3. after <WorkflowActions>
  4. In your new class add following method to create new recurring event.

 wf_action

class CreateCalendarRecurrenceEvent
    {
        public Hashtable CalendarRecurrenceEvent(SPUserCodeWorkflowContext context, stringeventTitle, string recurrenceRule)
        {
            Hashtable results = new Hashtable();
            int iYear = 0, iMonth = 0, iDay = 0;
         &nbsle CalendarRecurrenceEvent(SPUserCodeWorkflowContext context, stringeventTitle, string recurrenceRule)
        {
            Hashtable results = new p;  results["Except"] = string.Empty;
            try
            {
                using (SPSite site = new SPSite(context.CurrentWebUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {

                        iYear = DateTime.Now.Year; iMonth = DateTime.Now.Month; iDay =DateTime.Now.Day;
                        DateTime startTime = new DateTime(iYear, iMonth, iDay, 8, 0, 0); //
                        DateTime endTime = startTime.AddHours(6);

                        SPList cal = web.Lists["Calendar"];
                        SPListItem calEvent = cal.Items.Add();
                        calEvent["Title"] = eventTitle;
                        calEvent["RecurrenceData"] = recurrenceRule;
                        calEvent["EventType"] = 1;
                        calEvent["EventDate"] = startTime;
                        calEvent["EndDate"] = endTime;
                        calEvent["UID"] = System.Guid.NewGuid();
                        calEvent["Recurrence"] = 1;
                        calEvent.Update();
                    }
                }
            }
            catch (Exception ex)
            {
                results["Except"] = ex.ToString();
            }
            return results;
        }
    }

(NOTE: I have used default calendar list to create new recurring event, if you want to create recurring event in another calendar list then change 'Calendar' list name.
)
Build and deploy action and follow the steps given at  http://msdn.microsoft.com/en-us/office365trainingcourse_lab_3_2_topic3#_Toc290553044

In SharePoint Designer workflow, add your custom activity, assign Name and Recurrence Rule pattern as in XML format. You can check more recurrence patterns from Here.

(NOTE :  Rule value must be in single line text, I have used as " <recurrence><rule><firstDayOfWeek>su</firstDayOfWeek><repeat><daily dayFrequency='2' /></repeat><windowEnd>2011-12-30T09:00:00Z</windowEnd></rule></recurrence> ")
Enjoy custom activity to create new recurring events from SharePoint Designer workflow.
  
(Source Code: http://prudencesys.blogspot.com/2011/12/how-to-create-calendar-recurring-event.html )