0

My criteria is as follow:

  1. If I add an event in Calendar A , then I want the same event to be added in a different calendar B with some condition. So that I don't have to pick a specific item from that Calendar A and then add it manually in my calendar B.

It should automatically add an event in calendar B once entered in A, but Columns are different in both the Calendars so I want to map only the ones matching in both the Calendars.

How can this be done?

3 Answers 3

2

The easiest way to accomplish this is to use the function calendar overlay. On Calendar A you can overlay Calendar B and on Calendar B you can overlay calendar A. Once this have been set up you will find the entries of both calendar in Calendar A and B.

How this works an can be set up can be found in the SharePoint help: Overlay a SharePoint calendar on another SharePoint calendar

The calendar entries also have different colors then.

0

The following code for example will loop thru my Calendar list and delete the event with a specified ID, but you can put code in the inner code block which will take the values and write to different calendar.

        var myWeb = SPContext.Current.Web;
        var listItems = myWeb.Lists["Leave Calendar"].Items;
        var itemCount = listItems.Count;
        for (var k = 0; k < itemCount; k++)
        {
            var item = listItems[k];
            if (requestId == Convert.ToInt32(item["RequestID"]))
            {
                listItems.Delete(k);
                break;
            }
        }

And in the following code snippet is how I save items to a calendar

protected void WriteToCalendar(string title, string location, DateTime startdate, DateTime enddate, string description, string category, bool alldayevent, string requestid)
    {
        var myWeb = SPContext.Current.Web;
        var calendarList = myWeb.Lists["Leave Calendar"];
        var calendarListItem = calendarList.Items.Add();
        calendarListItem["Title"] = title;
        calendarListItem["Location"] = location;
        calendarListItem["Start Time"] = startdate;
        calendarListItem["End Time"] = enddate;
        calendarListItem["Description"] = description;
        calendarListItem["Category"] = category;
        calendarListItem["All Day Event"] = alldayevent;
        calendarListItem["RequestID"] = requestid;
        calendarListItem["Approval Status"] = "Pending";
        calendarListItem["Employee Name"] = title;
        myWeb.AllowUnsafeUpdates = true;
        calendarListItem.Update();
        myWeb.AllowUnsafeUpdates = false;
    }
1
  • I dont know where to apply this code as I am not a sharepoint developer and I just want to maintain calendar entries , i.e. one event added incalendar should automatically populate in Calendar B
    – akash
    Nov 22, 2013 at 12:09
0

Creating a Workflow in SharePoint Designer would be the easiest way to handle this, especially with evaluating your conditions and mapping differing columns up.

2

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.