Using a SharePoint Calendar with ComponentOne’s Scheduler for LightSwitch

This is a cross post… also posted on ComponentOne’s blog (“Using SharePoint Calendars with ComponentOne Scheduler for LightSwitch). To put it in context, Scheduler for LightSwitch is an extension that adds a calendar screen to a LightSwitch Project. You can download a trial over at ComponentOne.com if you are interested in kicking it around.

Microsoft Visual Studio LightSwitch has a great feature nobody talks about: the ability to use SharePoint as a data source. Data is created and stored in SharePoint all the time and that data is often useful in business applications. Imagine a project management or time management application, for example. Chances are that there is a SharePoint calendar somewhere that has useful data for that application.

ComponentOne Scheduler for LightSwitch extension gives you a snap-in Outlook scheduling application. All you need to do is add the screen to your project and select a data source. With this extension, you can add SharePoint calendar data to your LightSwitch application very easily.This article explains how you can use ComponentOne’s Scheduler for LightSwitch with a SharePoint calendar to create an Outlook-style scheduling application without code.

Setting up the Calendar Data Source

Scheduler for LightSwitch needs a table with seven fields to work properly. These fields are ID, Subject, StartTime, EndTime, Body, Location, and Properties. A standard SharePoint calendar has fields that can map to each, with the exception of Properties. You will need to create a Properties column.

Below are instructions to start from scratch. If you are using an existing calendar, make sure you first follow the instructions for creating a Properties column.

To create a new calendar, access SharePoint’s create list dialog, select Calendar, and name it.

Once the calendar is created, open the list setting page and click the Create Column link. Name the new column “Properties,” keep Single line of text selected and clear the Maximum number of characters field. There is often a large amount of data in the Properties field, so keeping the limit can cause errors.

Make sure you add at least one record to the list. A holiday is an easy example.

You now have a calendar that Scheduler for LightSwitch can use!

Creating the LightSwitch Application

Create a new LightSwitch project and select Attach to External Data Source from the start screen.  The Attach Data Source Wizard will open.

Select SharePoint and click Next.

Enter the URL to the site that hosts your calendar, select your login method, and click Next. Note that you just need the top level URL, not the path directly to the calendar. You will select that in the next screen.

Select the list (or lists) you would like to include, name it, and click Finish.

You should see a visual representation of the list in the LightSwitch designer.

Now, you can add the ComponentOne Scheduler screen. Click the Add Screen button, choose ComponentOne Calendar Screen, and select your list from the Screen Data drop-down.

When you click OK, you will see the design view for the Calendar screen you just created. The next major step is to map the screen data fields.

Click Holidays in the tree view and you will see Row Template properties appear in the Properties pane. Map the following:

  • Primary Key Property:  Id
  • Start Time Property: StartTime
  • End Time Property: EndTime
  • Subject Property: Title
  • Body Property: Description
  • Location Property: Location
  • Properties Property: Properties

You are now ready to run your new application.

Click the Start Debugging button or press F5.

You now have a basic scheduler application. This application will do the following:

  • Display items on the SharePoint calendar.
  • Allow you to export the entire calendar to iCal or XML.
  • Add events to the calendar one by one or import iCal or XML files. Anything entered will also appear in the SharePoint calendar.
  • Print a view.
  • Look at day, week, and timeline views.

More Features

Wait, there’s more!

By default, grouping is turned off. You can add a toolbar that allows users to group by resource, contact, or category. To turn the feature on, go to the screen designer, click on C1Scheduler, and check the Show Group Commands in the Properties pane.

Click the Start Debugging button.

You can also map more tables or lists to application.

To associate a separate data source (such as a contacts list), click Add Data Item to add the desired query to the screen. Add the collection to the end of the screen layout, then change the default control (DataGrid) to C1Contacts as shown in the following figure.

Note that the data item must exist and be part of the project. See the Adding Other Data Sources topic in the Scheduler for LightSwitch documentation for more details.

That’s All Folks

The combination of LightSwitch and ComponentOne Scheduler has made it very easy to create a scheduling application – even with SharePoint data. What are you using it for?

Advertisements
Tagged , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: