SharePointAds TextOnly

Thursday, 15 December 2011

How to create Calendar recurring event from SharePoint Designer 2010 workflow?

Do you want to create new calendar recurring event from SharePoint workflow? If yes, then you are at correct place.
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.
I found an interesting article which creates new calendar event with recurring parameters programatically( 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 (, 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. Your ‘Element.xml’ file would be as following,  

    <?xml version="1.0" encoding="utf-8"?>

    <Elements xmlns="">


        <Action Name="Create Recurring Event"






                Category="My Custom Workflow Activities">

          <RuleDesigner Sentence="Create New calendar recurring event with title : %1 and rule: %2 (Exception to %3)">

            <FieldBind Id="1" Field="eventTitle" Text="Event Name" DesignerType="TextBox" />

            <FieldBind Id="2"  Field="recurrenceRule" Text="Recurrence Rule" DesignerType="TextBox" />

            <FieldBind Id="3" Field="Except" Text="Exception" DesignerType="ParameterNames" />



            <Parameter Name="__Context"

                       Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions"

                       Direction="In" DesignerType="Hide"/>

            <Parameter Name="eventTitle" Type="System.String, mscorlib" Direction="In"

                       DesignerType="TextBox" Description="Event Name" />

            <Parameter Name="recurrenceRule" Type="System.String, mscorlib" Direction="In"

                       DesignerType="TextBox" Description="Recurrence Rule" />

            <Parameter Name="Except" Type="System.String, mscorlib" Direction="Out"

                       DesignerType="ParameterNames" Description="Exception encountered"/>






  3. In your new class add following method to create new recurring event.
class CreateCalendarRecurrenceEvent


        public Hashtable CalendarRecurrenceEvent(SPUserCodeWorkflowContext context, 
string eventTitle, string recurrenceRule)


            Hashtable results = new Hashtable();

            int iYear = 0, iMonth = 0, iDay = 0;

            results["Except"] = string.Empty;



                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;




            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

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>

I have created SPD custom activity solution on Codeplex, you can download actual project solution from here (

Enjoy custom activity to create new recurring events from SharePoint Designer workflow.