Useful SharePoint dlls

SharePoint has some great features like exporting list views to Excel or connecting Calendar events to your Outlook calendar. However, this might not always be easy for end users or users might not be willing to use the Ribbon menu to access these features (as in my case). Thankfully using REST, a little JavaScript can put this functionality directly onto a regular page as links to export to Excel or add an event to your Outlook calendar.

Exporting to Excel
In my first example, we had users who were rolling up list data onto a reporting page. From this page they wanted to export a different view of the list that we had set up for them. That, however, required them to navigate to the list and use the export to Excel button in the Ribbon menu:


On the reporting page, I added an Excel button with with a class Caption. With a line of JavaScript this can be set to the correct url:

var href = “http:// [sharepoint] / [site] /_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[List Guid]&View=[View Guid]&CacheControl=1”
$(“.Caption a”).prop(“href”, href);

This will give you a button to export whatever view of the list you would like to Excel:


As much as, I’d like to take credit for this discovery, check this link below for the thread and this link to another blog with that solution.

Add to Outlook Calendar
In my second example. we created a SharePoint calendar for users to manage events. A workflow sends them an email with the link to the event when they change the category of an event indicating that this is an event they will be attending.

Like the first example. this is also pretty simple. We created a calculated column with the value of the link below:
http:// [sharepoint] / [site] / [list] /_vti_bin/owssvr.dll?CS=109&Cmd=Display&List=[List Guid]&CacheControl=1&ID=&Using=event.ics

Notice the event.ics at the end which give us an ics file to create an Outlook calender event. This can then be included in the workflow email and will give them a link like the below:


Multiple check boxes default values

I recently had a requirement to have a choice column with check boxes and have all options selected by default. After a little hunting I came across the syntax which is rather easy:


In the default value box, select Calculated Value and enter the above.

This leads to check boxes being selected on item created.

SharePoint Calendars

Recently we had an interesting request on our SharePoint intranet: sharing between calendar but with an emphasis on bidirectional aggregation. If an event was updated in a sub site, it need to be reflected in the Master Calendar of the home page. OOTB, I’m not aware that this is possible, so we came up with an intermediary step: send an email to an Content Manager and have them “approve” or save the information to the Master Calendar. The email would include a link to the Master Calendar’s newform.aspx. We managed to accomplish this through a simple workflow and the magically powers of jQuery to auto fill the form for the Content Manager  with the information from the event to be shared in the Master Calendar.

On the sub-site calendars we created a new column for each list called Share With Master, then each calendar has a simple workflow when an item is created with the following logic:

If Share With Master = Yes
     Email Content Manager [of the Master Calendar] a link

The link sent to the Content Manager contains each of the field values filled out in the querystring. (it might look something like /newform.aspx?Title=test%20title&Location=test%20location)

The link opens newForm.aspx of the Master Calendar and we use jQuery to populate each field of newForm.aspx so the Content Manager just clicks save and “approves” the information. To parse out the above example we would do the following:

    //get parameters
    var title = getURLParameter('Title');
    var location = getURLParameter('Location');

    //remove characters like %20
    var parsedTitle = decodeURI(title);
    var parsedLocation = decodeURI(location);

    //assign to fields
    $("span input[title='Title']").val(parsedTitle);
    $("span input[title='Location']").val(parsedLocation);

This doesn’t give us the bidirectional functionality we were looking for but does allow us to easily share events between calendars. Currently, we’re looking in Bamboo Solutions’ Calendar Plus Web Part which looks like it might meet our requirements.