Sorry for the miscommunication.
It’s been awhile since I’ve posted any ground-breaking new discoveries, so I thought I would pass on a bit of info about the Group Calendar and displaying default groups. Disclaimer: this is still in beta, and not running on a production site yet.
I’ve stumbled across a few blog posts about the group calendar, and the need to display a default set of resources on the calendar. The OOB functionality requires the user to select a resource/resource group before items show up on the calendar. Being the stubborn developer that I am, I decided that I would come up with a fix for this based on a specific requirement from one of our Business Units. This solution works for Resource Groups, but I’m sure it can be modified to easily display resources or people, depending on your requirements.
Looking at the calendar in action, you will quickly realize that the calendar uses the picker dialog for selecting resources, and AJAX to render selected items on the calendar. So, how does one go about calling the necessary functions to populate the calendar? Magic! 😉
I started by viewing the source of the parent page to get an idea of what was actually taking place when the picker dialog closes. Here is the event you are looking for:
Great! But how does this help you? You may notice that the dialog result is xml, and that setting the result requires a call to SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(type, id). After a bit of searching in the SP.UI.Calendar.debug.js file, I found some information around the ResourceSelector and retrieving the selector type. If you do a search of the source code in your view source window for “add_resource”, you’ll see that the “Add Resources” link attribute “evtid” is “add_resource”. Searching through the SP.UI.Calendar.debug.js on “add_resource” yielded this handy bit of information:
This shows that the type is 1, and add = true. Once I had that information, I just needed to track down the XML data being passed from the picker dialog. That’s where Fiddler comes in. If you aren’t familiar with Fiddler, you should be. I won’t go into too much detail, but will give you the gist below.
First, I opened an instance of fiddler and launched IE, browsing to my home page (which contains my group calendar). I then clicked the “Add Resources” link, and added a Resource Group called “All Computers” and clicked “OK”.
You’ll see below that the events now display for each resource in the calendar.
I then went into fiddler, and took a look at the final request from Picker.aspx, and began scanning the TextView for any information that might be helpful.
var sel = SP.UI.ApplicationPages.CalendarSelector.instance().getSelector(1, $(el).attr(‘ctxid’)); sel.selectEntities(xml, true); }
As always, if you have any questions, feel free to ping me. Hopefully, this will save you some time and make you look like a rockstar!