As most if not all of you already know, SharePoint 2013 and Office 2013 has been released to preview/beta and is available for download from Microsoft’s download centers. In this article I will briefly introduce some exciting changes that has been made to the SharePoint 2013 Business Connectivity Services framework. I’ve written a bunch of articles on BCS for SharePoint 2010, and now it’s time to continue that track and introduce the new features available in SharePoint 2013.
Please note that this article is written for SharePoint 2013 Preview, and for the final version of SharePoint some details may have changed
- SharePoint 2013: Business Connectivity Services – Introduction
- SharePoint 2013: Business Connectivity Services – Consuming OData in BCS Using an App External Content Type
- SharePoint 2013: Business Connectivity Services – Talking to your external lists using REST
- SharePoint 2013: Business Connectivity Services – Client Object Model
- SharePoint 2013: Business Connectivity Services – Events and Alerts
SharePoint 2013 – BCS with OData
In this specific article we’ll be looking on how you can consume data from an Open Data protocol (OData) data source. Tag along for the ride!
First of all, tell me what OData is…!?
Right, so OData is a Web protocol for performing CRUD (Create Read Update and Delete) operations and utilizes technologies like HTTP, ATOM and JSON.
As quoted from the OData Web Site:
The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today.
OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores.
We can have lengthy discussions about how awesome (or unawesome) OData is but in this article we’ll be focusing on consuming OData data sources in SharePoint 2013 through Business Connectivity Services, one of my favorite parts of SharePoint.
Launch Visual Studio and get started!
So, as you probably could tell by the title of this post – you should now open Visual Studio 2012 :-)
Create the project
Choose the project type App for SharePoint 2013:
The Wizard that launches will give you a few choices which we’ll discuss in another article. In this article I’ve selected the “SharePoint Hosted” alternative, as you can see below:
This should get you setup with the initial project structure, and you should now have a project that looks something like this:
Add an external content type
Now that we’ve created our initial project, we should add a new external content type. If you right-click your project and choose Add, you can see that there’s a new menu item called “Content Types for an External Data Source…“. Click it:
In the following wizard, you can enter the service URL for the OData provider you’d like to consume. In my example I’ve used the public tv.telerik.com/services/odata.svc OData service:
In the next step in the wizard, you get to select for which data entities you want to generate external content types. Choose the entities you’d like to work with and continue by pressing Finish:
Please note that you should leave the “Create list instances for the selected data entries (except Service Operations).” checked so the tools can create your external list automatically!
After we’ve completed this step, we can see a few additions in our project that Visual Studio 2012 has been so kind to help us out with.
A Telerik Video external content type with it’s associated ListInstances (one per entity, in my case only one for Video) that it was also kind enough to create for us since I had the checkbox in the previous dialog ticked:
Looking in your Feature explorer, you can see that the default Feature now contains your artifacts along with the newly created List Instance and External Content Type:
In the newly created List Instances, the following XML has been generated for us:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ListInstance Url="Lists/Video" Description="Video" OnQuickLaunch="TRUE" Title="Video"> <DataSource> <Property Name="LobSystemInstance" Value="Telerik OData" /> <Property Name="EntityNamespace" Value="TelerikTvDataServiceDataServiceModels" /> <Property Name="Entity" Value="Video" /> <Property Name="SpecificFinder" Value="ReadSpecificVideo" /> <Property Name="MetadataCatalogFileName" Value="BDCMetadata.bdcm" /> </DataSource> </ListInstance> </Elements>
As you can see, the ListInstance DataSource node contains information about connecting to our newly created BCS entity. Perfect.
Just to make sure that we can deploy our solution, hit F5 and make sure that VS2012 deploys your project properly
Validate that your application works
Navigate to your site and validate that your new App is properly deployed and showing:
Click the app and make sure you can see the result of your very basic and “hello world”-ish app:
Display your new external list!
Do you remember in one of the previous steps that I mentioned that you should leave the checkbox ticked in a dialog, saying “Create list instances for the selected data entries (except Service Operations).”? Well the reason for that is that we want Visual Studio 2012 tools to create this list for us so we don’t have to do that ourselves.
With the newly deployed BCS external content type app, with it’s created list, you can access the content of the list on the following URL (you’ll need to check your Elements.xml for your ListInstance element in order to find out your url:
Navigate to this URL and you’ll see this view:
So that’s pretty cool and easy right? Straight from the XML-formatted OData source we’ve pulled some info into our App in SharePoint.
As you can see, working with SharePoint 2013 and the OData model with BCS is pretty straight forward. In this example I created an App for SharePoint utilizing the BCS framework to connect to an OData data source. I’m pretty impressed with the options this opens up for many of our existing SharePoint 2010 projects that sometime in the future will be upgraded to SharePoint 2013.
In the next few posts we’ll dive more into the news around BCS for SharePoint 2013.
Latest posts by Tobias Zimmergren (see all)
- Integrate SharePoint Code Analysis Framework (SPCAF) in your TeamCity build configurations–Improving your SharePoint and Office 365 ALM - April 13, 2015
- Office 365 API Sandbox – Learn how to use the API’s with your own tenant data! - February 3, 2015
- Getting Started with building Azure WebJobs ("Timer Jobs") for your Office 365 sites - January 9, 2015