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.

Entity Framework Database First Walkthrough

This walk-through will cover how set up entity framework with a database first approach:

1. Install Entity Framework 4.1

http://www.microsoft.com/en-us/download/details.aspx?id=8363

2. Begin a new Project

Create a new model:

Right click on project–> add new item
Select data from the menu
Select ADO.Net Entity Data Model
Enter a name
Click add

Follow the prompts and to map to an existing database (ex. use a connection string)

3. Use dbContext code generation

On the design surface of the edmx model:

Right click–> add code generation item
Select code from the menu
Select ADO.Net dbContext generator
Enter a name (helps if this is the same as your model name)
Click add

This will create two new items in your project
[yourname].tt
Which will contain simple POCO classes for each entity in your model
[yourname].tt
Which will generate a drived dbContext to use for getting and changing data

4. Manipulate data

As an example, map to a gridview:

<asp:GridView ID=”GridView1″ AutoGenerateColumns=”false” runat=”server”>
<Columns>
<asp:BoundField DataField=”Category” HeaderText=”Category” />
<asp:BoundField DataField=”CreatedByUserName” HeaderText=”User” />
<asp:BoundField DataField=”DateTime” HeaderText=”DateTime” />
</Columns>
</asp:GridView>

In the code behind:

InsightEntities topic = new InsightEntities();
GridView1.DataSource = topic.Topics.ToList();
GridView1.DataBind();

Here InsightEntites is the name of our contextClass.

This will something like produce the following:

Category User DateTime
test category test user 09/01/2013