SharePoint Group Calendar, Adding default users

The Problem

One feature of SharePoint is to create a calendar and make it a group calendar. This allows the user to see the schedule of list of people at the same time on the same view as per the image below.


To configure the Calendar as a group Calendar you need to edit the List settings and then click on “List name, description and navigation” and finally select the radio button as per the image below.


So all this is SharePoint out of the box functionality. So where is the problem?

The problem is that to get the view of all calendar of your work group every time you open the calendar view you need to add each one of them individually! And I could not find any way to persist this information so that it would open the calendar view automatically with the people added as per the list you see in the first image. So lets get to work.

The Solution

The way I fixed this is using Java script.

To be able to do this I used the following script.

var sel = SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1, 'WPQ12');
sel.selectEntities(ret, true);

You need two things to be able to perform the above script, the ID of the calendar web part (WPQ12 above) and the XML script to be able to add the required individuals. The way to do this is to follow the following steps:

Step 1: Getting the XML to add the required users

  1. Install and start Fiddler
  2. Click on the ribbon on the small arrow below “people” then “Add Person or Group”
  3. This will give you the dialog to select the users, add all required users to be added by default to the Calendar view and then click “Ok” as image below
  4. See Fiddler log to find an entry to add the users as per the below.
  5. Then click on the response as text view you will find the Entities string as per the image below.
  6. Copy this text to be used later in your script.

Step 2: Getting the web part ID

  1. Open the page with the calendar web part
  2. Open the IE developer tools (F12)
  3. Click on the selector arrow and then on the calendar web part (most top level)
  4. In the developer tools view you should see Id of the web part as below

Step 3: Create the required script file

  1. Use the information gathered to construct a JS file as below

function _firstTime() {

//need to select the calendar tab so we can override the onlick method on some of the buttons.
SelectRibbonTab('Ribbon.Calendar.Calendar', true);

//give the ribbon time to load


function _doWireUp()
//change the onclick event for the group buttons to make sure it reloads our default group
var weekElem = document.getElementById('Ribbon.Calendar.Calendar.Scope.WeekGroup-Large');
weekElem.onclick = function() {setTimeout('_setDefaultResources();',1000);return false;};

var dayElem = document.getElementById('Ribbon.Calendar.Calendar.Scope.DayGroup-Large');

dayElem.onclick = function() {setTimeout('_setDefaultResources();',1000);return false;};


function _setDefaultResources() {

// This is the entities XML from step1
    var ret ='\u003cEntities c…………………………………………………………………………………………………………..\u002fEntities\u003e';

// Put here the web part ID from step 2

        var sel = SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1, 'WPQ12');
        sel.selectEntities(ret, true);

ExecuteOrDelayUntilScriptLoaded(_firstTime, "sp.ribbon.js");

  1. Save the file as cal.js (any name)

Step 4: Configure the web page

  1. Upload the JS file to any accessible location on SharePoint such as the styles library
  2. Check it in and publish it if required
  3. Edit the page with the calendar web part and add a content editor web part to the bottom of the page
  4. Edit the source of the content editor web part and add the following line
    <script src="/sites/<your site name>/Style%20Library/ctrl/cal.js" type="text/javascript"></script>
  5. Save the page and then reload it.
  6. See the magic happen 🙂

Comments (28)

  1. Anonymous says:

    Follow this link to link the js file via a content editor web part.

  2. Anonymous says:

    Hi, I’m unable to add script content editor (Step 4). getting error message as "

    tags are not supported in html…" can anyone please explain me how to add JS script in content editor….
  3. sabina Ansari says:

    Hi I am unable to find the var ret by using fiddler any detail description how to find or any other alternate solution to this will be higly appreciated.

    Thanx in advance.



  4. Arthur Reyes says:

    @Sabina – You may see "Response is encoded and may need to be decoded before inspection.  Click here to transform."  Above the Text view.  Click that box.

    You may also need to go into Fiddler Options, and select "Decrypt HTTPS traffic"

    I'm still struggling with Step 4, myself …

  5. Mani says:

    You should use the ID as ‘WPQ2’ to make it work.

    var sel = SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1, ‘WPQ2’);

    Thanks for the detailed post !! It works !!

  6. Chris says:

    I tried setting this up but when I look at the IE Dev Console I see an error sayin “Unable to get property ‘selectEntities’ of undefined or null reference”

    Followed the steps provided and got the XML but doesn’t seem to be rendering, help!

  7. EDDIE says:

    This worked great! One question though, when you switch to other views such as “Day”, “Week”, or “Month” and then go back to the “Week Group” view, the set of default users are no longer there. Can this be worked around as well? Thanks!

  8. Anonymous says:

    Pingback from Create a color coded group calendar for SharePoint Tutorial

  9. StephenP says:

    When I add the users and click OK, I don’t get any new entries in Fiddler. As far as I can tell, it’s definitely connected to the IE window in question, as an entry appears when I click to bring up the "add users" window (Host= Tunnel to; URL = our sharepoint
    address; Process = iexplore).

    Any ideas why this might be? Thanks!

  10. Mauricio says:

    It’s possible apply such functionality in recurrent events? i’m trying in sharepoint code behind, but i have a lot of problems for make him possible, any help will be much appreciated.

  11. zmzm says:

    it works well. Its a magic Thanks

  12. Allen R says:

    Thank you very much for this post!! Works well and loads all resources at load time. You the man.

  13. michszym says:

    It works for me one week but after I installed last updates for Windows and sharepoint 2013 foundation it stopped working and I can’t fix it 🙁 have you any idea what I should to do? just uninstall last updates?

  14. Al says:

    WOW how ridiculous!!!! This is something that should work out of the box and you need coding for this?????

    MS WAKE UP!!!!

  15. E says:

    Ridiculous what a simple function, why doesnt it work at the click of a button and why on earth would you only want to do this "temporarily" as MS put it.

    Cant belive all this work for something that should be out of box (as above)

  16. RC says:

    I have SharePoint online and I am not able to get this to work. Does this script not work with Office 365?

  17. EMR says:

    Great work you did!
    I have a question regarding all this cool functionality. Is there a way to show a "Month Group" view??
    There are "Day Group" and "Week Group", and my users would be happy to see all the events that are going to happen in the month at the same time. Something like a ribbon with the text "Month Group"…
    Thank you

  18. Kin says:

    Hi Its Working fine for me..But the problem is Whenever i am creating new item in calendar list,By default all resources are selected.How can i overcome this issue?

  19. SharePoint 2013 Developer training Online says:

    Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.">SharePoint 2013 Developer training Online

  20. SharePoint online training says:

    Simply superb explanation about SharePoint Group Calendar, Adding default users.

  21. ashraf says:

    Does this work on Office 365 (SharePoint online)?? Thanks

  22. ashraf says: works on SharePoint online.

  23. Hari says:

    I am able to see only two users

  24. kburg says:

    hoping people still follow this post. Same issue as michszym. This script doesn’t seem to work after the lastet round of Sharepoint updates. Any ideas as I really need to find a way for this to work.

  25. GB says:

    Wow, it works like a charm!

  26. Joister says:

    Sorry guys, I’m not a programmer, I did follow all steps and not able to make it work, I did found both required codes from step 1 and 2, I uploaded the .js file to style library, help?

  27. BG says:

    Thanks for the post. It works but there are two issues I would llike to ask;
    First, everytime I add a specific group from "People Selector", somehow I see system account as well.

    Second, When I add calendar to a page as web part, it does not show any content.

Skip to main content