Thursday, June 9, 2016

SharePoint calendar color coding for non-power users

SharePoint calendar color coding is the one of the most common requests. It can be hard to find a required event quickly when all of the events are the same color.

In this article we will describe 3 possible ways to solve the SharePoint calendar color coding issue.


SharePoint calendar color coding using SharePoint calendar overlay
The simplest solution for SharePoint calendar color coding is SharePoint calendar overlay.

Go to your calendar List settings and create a Choice column.

SharePoint calendar color coding 1



Then fill in choice types for SharePoint calendar color coding that you would like for this calendar. In our case, they are Meetings, work hours and Birthday.

SharePoint calendar color coding 2


Save the changes.

Now create a new “Calendar view” for this calendar.

SharePoint calendar color coding 3


Type the view name as you have the first choice in the event types.

SharePoint calendar color coding 4
Then adjust a filter.
SharePoint calendar color coding 5


Save the view. Then do the same operation with other event types and create 2 more views.

Now we need to perform SharePoint calendar overlay. Click SharePoint calendar overlay icon on the ribbon and create a new calendar.


SharePoint calendar color coding 6


Type the calendar name and choose a SharePoint calendar color for it.

SharePoint calendar color coding 7


Then create additional calendars for other event types.


SharePoint calendar color coding 8
Now you should ensure the duplicate events are missing in your overlapped calendars like on the screen below.

SharePoint calendar color coding 9


To do this, click Modify view and clear filter field in the default calendar or in any other calendar, which is used for SharePoint calendar color coding.


SharePoint calendar color coding 10
And now we have all events with distinct colors using SharePoint calendar overlay feature.

SharePoint calendar color coding 11

SharePoint calendar color coding with a script.

Another approach to SharePoint calendar color coding is namely coding.

First at all, create a new column in your calendar for event categories. In our example, it is called "Event type". 


SharePoint calendar color coding 12
Now create another column, select “calculated” type and add the formula “|||” & [Event type] & “|||” & [Title]

Of course, you can type any other column name instead "Event type".

SharePoint calendar color coding 13

Now create new or modify the default view of your SharePoint calendar and change the month, week and day view’s fields to the name of created column. 

SharePoint calendar color coding 14

Now add the following script into the content editor. Choose “Click here to add new content”, then “Edit Source”, paste the script and click “Save“.

<style>
    .ms-acal-item{
        display:none;
    }
 </style>
 <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js" type="text/javascript"></script>
 <script type="text/javascript">
 var shouldcolortext = true;
LoadSodByKey("SP.UI.ApplicationPages.Calendar.js", function () {
    window.setTimeout(ColorCodeCalendar, 1000);
});
var sep = "|||";
function ColorCodeCalendar() {
    var bodyContainer = jQuery('#s4-bodyContainer');
    var q = 'a:contains(' + sep + ')';
    if (bodyContainer.find(q).length > 0) {
        bodyContainer.find(q).each(function (i) {
            var div = jQuery(this).parents('div[title]');
            var colors = GetColorCodeFromCategory(GetCategory(this.innerHTML));
            var anchor = jQuery(this);
            anchor.text(GetText(anchor.text()))
            div.attr("title", GetText(box.attr("title")));
            div.css('background-color', colors[0]);
            div.css('display', 'block');
            if (shouldcolortext) {
                div.find('div, a').css("cssText", "color: " + colors[1] + " !important;");
            }
        });
    }
    window.setTimeout(ColorCodeCalendar, 2000);
}
function GetText(originalText) {
    var parts = originalText.split(SEPARATOR);
    return parts[0] + parts[2];
}
function GetCategory(originalText) {
    var parts = originalText.split(SEPARATOR);
    return parts[1];
}
function GetColorCodeFromCategory(category) {
    var bg = null;
    var fg = null;
    switch (category.trim()) {
        case 'Meetings':
            bg = '#ECD078';
            fg = '#000000';
            break;
        case 'Work hours':
            bg = '#D95B43';
            fg = '#000000';
            break;
        case 'Birthday':
            bg = '#C02942';
            fg = '#000000';
            break;
    }
    return [bg, fg];
}
 </script>


You can also choose another SharePoint calendar color. Now you can display your events on site page with SharePoint calendar color coding.


A third-party solution for SharePoint calendar color coding.

The most simple way to choose any SharePoint calendar color for your events without coding and time consuming adjustments is the ready-to-use web parts and add-ins.

Virto Calendar for SharePoint Online, SharePoint 2013, 2010 and 2007 is a powerful enterprise-class scheduling solution, that overlays all your events from cross-site collection calendars and from any SharePoint or Exchange Online (Outlook) calendars. 

With Virto SharePoint calendar, you can customize SharePoint calendar color for each data source with a few clicks!

SharePoint calendar color coding 15

And the awesome feature from the latest update is the ability to choose a color marker according to event type.

SharePoint calendar color coding 16


The color marker on the left side of events is corresponded to the data source color.

SharePoint calendar color coding 17

Also, you can perform the SharePoint calendar overlay with a single click and display any number of SharePoint and shared Exchange Online Calendars into one calendar!

Virto SharePoint calendar color coding makes it easier for users to see items on a calendar!
You can download the 30-days free trial of Virto SharePoint calendar and try all its awesome features!

Virto SharePoint calendar for SharePoint 2013, 2010, 2007.