Posts Tagged ‘BCS’

Introduction

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

  1. SharePoint 2013: Business Connectivity Services – Introduction
  2. SharePoint 2013: Business Connectivity Services – Consuming OData in BCS Using an App External Content Type
  3. SharePoint 2013: Business Connectivity Services – Talking to your external lists using REST
  4. SharePoint 2013: Business Connectivity Services – Client Object Model
  5. SharePoint 2013: Business Connectivity Services – Events and Alerts

SharePoint 2013 – BCS with REST

In this article we’ll be taking a further look on the new Business Connectivity Services changes and additions in SharePoint 2013. I want to take a quick look and introduce how REST (Representational State Transfer) can be used and also how the Client Object Model can be utilized to communicate with your External Lists and BCS Entities.

So without further delays, let’s dig into the fantastic world of BCS and CSA (Client Side Awesomeness).

Important: The project type in this project, as mentioned in the post where we started building our sample, is a SharePoint-hosted app.

Business Connectivity Services and REST

Utilizing REST in BCS in your SharePoint 2013 environments isn’t really that big of a deal. It’s pretty straight forward. The first thing you should do is take a look at the following link which references the MSDN article about getting started with REST in SharePoint 2013.

MSDN Reference: http://tz.nu/QXfooY

So now that we know that REST is all about, we’re going to look at some code that will utilize REST to retrieve some data. In this sample I’ll continue to build on the solution I created in the previous article.

Final result will look like this

When our first snippet of code will be done, it’ll look something like this where our (in this case) App (page) is loaded:

image

So what the code will do is to pull out the images and links for the videos in the Telerik.Tv OData data source that we created in the previous article, and we’ll be doing this using the REST API’s.

In one big snippet, here’s what the REST call looks like in my App.js:

var context;
var web;
var user;

function sharePointReady()
{
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('Video')/items";
    jqxhr = $.getJSON(requestUri, null, onSuccessfullJSONCall);
    jqxhr.error(onErrorInJSONCall);
}

function onSuccessfullJSONCall(data) {

    var outputHtml = "";
    var results = data.d.results;
    var counter = 0;
    for (var i = 0; i < results.length; i++) {
        outputHtml += "<img src='" + results[i].ImageUrl + "' class='brick-image' />";
        counter++;

        if (counter >= 4) {
            outputHtml += "<br/>";
            counter = 0;
        }
    }

    $("#message").html(outputHtml);
}

function onErrorInJSONCall(err) {
    $("#message").text("Unawesome Error: " + JSON.stringify(err));
}

As you can see in the aforementioned code snippet, the calls to the REST API’s are pretty straight forward and I’m only making a quick call to fetch the data asynchronously using the $.getJSON() method.

Lets break it down in sections..

Script part 1: sharePointReady() method call

Since our project type (a SharePoint-hosted App) contains a stub for the Default.aspx page and the App.js files – a method called sharePointReady is defined in the App.js file and in the Default.aspx you have the following block which initiates the call to this method upon loading all other required awesome things:

    <!-- The following script runs when the DOM is ready. The inline code uses a SharePoint feature to ensure -->
    <!-- The SharePoint script file sp.js is loaded and will then execute the sharePointReady() function in App.js -->
    <script type="text/javascript">
        $(document).ready(function () {
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { sharePointReady(); });
        });
    </script>

(Optionally, you can put this code-block in the actual App.js file as well if you’d like – it’s up to you)

When SharePoint is done loading all the required stuff that it needs to function (sp.js), this method is executed. In this sample, I’m making a simple JSON call to the REST API using the syntax http://url/_api/lists/getbytitle(‘ListTitle’)/items which will get all list items in the list named Video:

function sharePointReady()
{
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('Video')/items";
    jqxhr = $.getJSON(requestUri, null, onSuccessfullJSONCall);
    jqxhr.error(onErrorInJSONCall);
}

Script part 2: On successful JSON callback, the following block is executed

We’re executing the onSuccessfullJSONCall() when our previous call is successful, and it’ll basically just parse the JSON result and push the items out in a simple HTML structure:

function onSuccessfullJSONCall(data) {

    var outputHtml = "";
    var results = data.d.results;
    var counter = 0;
    for (var i = 0; i < results.length; i++) {
        outputHtml += "<img src='" + results[i].ImageUrl + "' class='brick-image' />";
        counter++;

        if (counter >= 4) {
            outputHtml += "<br/>";
            counter = 0;
        }
    }

    $("#message").html(outputHtml);
}

Script part 3: In case of unawesomeness (failure)

In case the request failed, we’ll be handling that somehow in this method. In this case we’ll just be printing out the error message very quickly to the user:

function onErrorInJSONCall(err) {
    $("#message").text("Unawesome Error: " + JSON.stringify(err));
}

Summary

In this article we took a very quick look at how to get that first REST call working with SharePoint 2013 against our External List called “video”. With the returned result in JSON, we’re parsing it out and simply rendering the result in a more reader-friendly manner as pictures in a simple HTML grid.

So that’ll be it for the REST calls for now. It should get you started and set-up for creating a very simple application that utilizes REST for retrieving data from SharePoint.

More details on working with the REST API’s in SharePoint 2013 will follow later, including how to perform cross-domain queries.

Enjoy.

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

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

  1. SharePoint 2013: Business Connectivity Services – Introduction
  2. SharePoint 2013: Business Connectivity Services – Consuming OData in BCS Using an App External Content Type
  3. SharePoint 2013: Business Connectivity Services – Talking to your external lists using REST
  4. SharePoint 2013: Business Connectivity Services – Client Object Model
  5. 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:

SharePoint 2013 bcs odata app

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:

SharePoint 2013 bcs odata app

This should get you setup with the initial project structure, and you should now have a project that looks something like this:

SharePoint 2013 bcs odata app project

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:

SharePoint 2013 bcs content type

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:

Telerik OData in SharePoint 2013

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!

SharePoint 2013 BCS Entity

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:

image

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:

image

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:

SharePoint 2013 app

Click the app and make sure you can see the result of your very basic and “hello world”-ish app:

image

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:

http://yourappurl/ZimmergrenSP2013BCSOData/Lists/Video

Navigate to this URL and you’ll see this view:

SharePoint 2013 BCS OData Telerik Tv

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.

Summary

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.

Enjoy.

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

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.

At the time of this writing, I’m looking into details about upgrading a SharePoint 2010 solution to SharePoint 2013 for one of my clients who rely heavily on BCS – and the new features in 2013 are pretty slick – so I’ll be documenting and writing about some of the new enhancements for developers in this series!

Please note that this article is written for SharePoint 2013 Preview, and for the final version of SharePoint some details may have changed

  1. SharePoint 2013: Business Connectivity Services – Introduction
  2. SharePoint 2013: Business Connectivity Services – Consuming OData in BCS Using an App External Content Type
  3. SharePoint 2013: Business Connectivity Services – Talking to your external lists using REST
  4. SharePoint 2013: Business Connectivity Services – Client Object Model
  5. SharePoint 2013: Business Connectivity Services – Events and Alerts

SharePoint 2013 – Enhancing your BCS experience

After playing around and digging into the BCS playground for a while, these are some of the initial enhancements I’ve discovered and played with:

Support for OData in BCS

With SharePoint 2013 we now have access to the so called "Open Data protocol", or OData. This is a protocol that enables us to access data sources in a way that we haven’t been able to previously – using specially constructed URL’s.

Read more on OData here: http://www.odata.org/ecosystem

In the next article in this series, I will talk about how you can consume OData through BCS in a SharePoint 2013 solution. Stay tuned!

Events and Alerts from external systems

One of the features we’ve missed in a lot of our solutions built on BCS is the ability to simply hook up an alert or trigger an event when things happen in the BCS data source. In SharePoint 2013 this has been addressed and we now have the ability to actually trigger some events and subscribe to alerts. Exciting news indeed.

This is pretty cool and lets the external data source notify SharePoint about things that has changed and trigger some kind of action as a response to that. Read more about Events and Alerts for BCS

In one of the next articles in this series, I will talk about events and alerts more thoroughly and walk you through the process of creating a solution and subscribe to events happening in the data source. Happy times!

Building App-scoped External Content Types

Have you heard about the new App-model for SharePoint and Office? Well if you haven’t, go to Bing.com and perform a search for it and check it out – AWESOME!

Anyway, I’ve been looking a lot on Apps lately, and that obviously means a lot of thoughts coming together around the topic. One thing I’ve found that is pretty interesting, speaking of BCS, is that you can create an App-scoped external content type to consume external data. This esseitnally means that you don’t have to deploy your solution to the Farm anymore, but can deploy it as an App instead.

In one of the next articles in this series, I will talk about building App-scoped external content types. Until then, you can find more info here: App-scoped external content types in SharePoint 2013

Enhanced support for the Client Object Model / REST

Obviously one of the heavy pushes Microsoft is doing, is to focus a lot on the Client API’s. With this focus there has been some improvements in terms of working with BCS Entities from the Client Object Model as well. There has been some pretty neat enhancements, which I will discuss in one of the articles in this series as well. Until then, take a look here: Get started using the client object model with external data in SharePoint 2013

Summary

This is the first post laying out the topics of my next few BCS articles for SharePoint 2013. If there’s something you’d like to explore or talk about, feel free to drop a comment and I’ll see if it can make it into the article series.

Enjoy.

Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren

Introduction

As many of you know, customizing a form for a SharePoint list isn’t very tricky to do – but when it comes to modifying the forms for an External List it becomes a bit more of a challenge. In this article I will walk you through how the BCS (Business Connectivity Services) model can enable you to modify the New- and Editforms by creating and utilizing your own Custom Field Controls and I will also talk about how you can change the behavior and rendering of your DisplayForm using jQuery.

Related articles about BCS that may be worthwhile:

Scenario

So let’s pose that our scenario is that we’ve got a a source of data coming in through BCS and is represented like it’s always represented out of the box with BCS. What we would like to do is to customize the New- and EditForms to allow custom logic and we would also like to change how the DispForm behaves.

In this sample we’ve got a very simplistic BCS model containing one entity with these properties:

  • Identifier (string)
  • Color (string)
  • Published (boolean)

    In SharePoint, our model is represented like this in the out of the box UI:

    Display Form New- and Edit Forms
    ScreenShot1530 image

    What we really want to achieve in this article is to manipulate the behavior of our Display- and New/Edit forms to look something like this:

    Display Form
    Published: Icon instead of Yes/No text.
    Color: Lit up with the selected color in the UI.
    New- and Edit Forms
    Color: Replaced with a custom field control
    image image

    As you can see in the last two images above, the result of our development is that we’ll be using a custom control (DropDown) instead of the standard TextBox for our Color-field, and we’ll change the way the Published-field looks in the Display Form. It should give you an idea of how you can customize and alter the behavior of your BCS External List Forms.

    So without further ado, let’s get started with modifying our forms!

    (I assume that you already have a BCS Model in place and will not iterate the steps for creating one here…)

    Modifying New/Edit forms: Custom Field Control to the rescue

    When it comes to the BCS Model, you should really always edit it through the XML and not through the Visual Studio UI. Start by right-clicking your BCS Model and selecting the "Open With…" alternative:
    image

    Then choose your favorite XML editor:
    image

    When you’re in this mode, you obviously have to be careful not to mistype or misspell anything as it can result in a broken BCS Model. Awesome :-)

    To cut it short, here’s an extract for the "Creating" Method, which references a Custom Field Control called ColorField:

                <Method Name="Create">
                  <Parameters>
                    <Parameter Name="returnEntity1" Direction="Return">
                      <TypeDescriptor Name="ReturnEntity1" TypeName="TOZIT.Samples.BCSExtensions.BdcModel1.Entity1, BdcModel1">
                        <TypeDescriptors>
                          <TypeDescriptor Name="Identifier1" IdentifierName="Identifier1" TypeName="System.String" />
                          <TypeDescriptor Name="Published" IsCollection="false" TypeName="System.Boolean" />
                          <TypeDescriptor Name="Color" TypeName="System.String">
                            <Properties>
                              <Property Name="SPCustomFieldType" Type="System.String">ColorField</Property>
                            </Properties>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </Parameter>
                    <Parameter Name="newEntity1" Direction="In">
                      <TypeDescriptor Name="NewEntity1" TypeName="TOZIT.Samples.BCSExtensions.BdcModel1.Entity1, BdcModel1">
                        <TypeDescriptors>
                          <TypeDescriptor Name="Identifier1" IdentifierName="Identifier1" TypeName="System.String" CreatorField="true" />
                          <TypeDescriptor Name="Published" IsCollection="false" TypeName="System.Boolean" CreatorField="true" />
                          <TypeDescriptor Name="Color" TypeName="System.String" CreatorField="true">
                            <Properties>
                              <Property Name="SPCustomFieldType" Type="System.String">ColorField</Property>
                            </Properties>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </Parameter>
                  </Parameters>
                  <MethodInstances>
                    <MethodInstance Name="Create" Type="Creator" ReturnParameterName="returnEntity1" ReturnTypeDescriptorPath="ReturnEntity1" />
                  </MethodInstances>
                </Method>

    As you can see above I’ve referenced a property called "SPCustomFieldType" in the code (Read more on BCS Custom Properties), which in turn is referencing something called "ColorField". The ColorField is my CustomField control that is simply a DropDown-box to be represented in the UI instead of the good’ol text box.

    Modifying Display Forms: jQuery to the rescue

    When it comes to modifying the DispForm of the External List, I’ve had several attempts with the documented RendererDefinition in the past and not one single time it worked for me nor any of my clients. So with that experience, I’ve resorted to using jQuery to modify the rendition of the Display Form. Obviously one could use jQuery for the New- and Edit Forms as well, if you want to.

    Short story, the jQuery looks like this:

    // Found this through google, but can't remember the source. 
    // Great script for string replacements!
    String.prototype.replaceAll = function (str1, str2, ignore) {
        return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof (str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);
    };
    
    $(document).ready(function () 
    {
        // Render an icon instead of Yes/No text
        var publishedHtml = $('h3.ms-standardheader:contains("Published")').closest('tr').children(".ms-formbody").html().toString();
        publishedHtml = publishedHtml.replaceAll("Yes", "<img src='/_layouts/images/TOZIT.Samples.BCSExtensions/checked.png' />");
        publishedHtml = publishedHtml.replaceAll("No", "<img src='/_layouts/images/TOZIT.Samples.BCSExtensions/unchecked.png' />");
        $('h3.ms-standardheader:contains("Published")').closest('tr').children(".ms-formbody").html(publishedHtml);
    
        // Render the entire TD in the color that was chosen
        var colorHtml = $('h3.ms-standardheader:contains("Color")').closest('tr').children(".ms-formbody").html().toString();
        var colorHtmlTd = $('h3.ms-standardheader:contains("Color")').closest('tr').children(".ms-formbody").attr("style", "background-color:" + colorHtml + ";");
    });

    Essentially what this jQuery snippet does is that it will find the correct elements in the HTML markup that corresponds to my Fields (you see the :contains("Published") part? That’s where I find the Published-field in the markup). Then I simply alter the text that is sent to us from the server, replacing "Yes/No" with an image of a checked or unchecked checkbox. Pretty simple trick to light up the form a bit without the hassle of trying to get your RendererDefinition working…

    Tip: If you want to easily inject your jQuery to the External List Forms, I’d recommend using a DelegateControl override on the AdditionalPageHead. The code for my AdditionalPageHead DelegateControl looks something like this:

            protected void Page_Load(object sender, EventArgs e)
            {
                string httpRequestUrlString = HttpContext.Current.Request.Url.AbsoluteUri;
    
                // Note: You should create a smarter verification for when to load the scripts than to use a hardcoded value like I've done in this sample. 
                if ((httpRequestUrlString.Contains("/Lists/Sample Entity/") || httpRequestUrlString.Contains("/Lists/Sample%20Entity/")) && httpRequestUrlString.Contains("DispForm.aspx")) // Only render scripts if it's the Display Form on the Sample Entity list
                {
                    // Add a reference to jQuery if it isn't already loaded
                    ScriptLink.Register(this.Page, "/_layouts/TOZIT.Samples.BCSExtensions/Scripts/jquery-1.7.2.min.js", false);
                    ScriptLink.Register(this.Page, "/_layouts/TOZIT.Samples.BCSExtensions/Scripts/bcsDisplayFormScriptSample.js", false);
                }
            }


    The code snippet above simply checks the current request and determines whether it’s your specific list being loaded, and then also determine if it’s the DispForm.aspx file being served. As noted in the comments, you should modify this if-statement to suit your needs, should you decide to create a DelegateControl like this.

    Summary

    Working with BCS is both fun and challenging at the same time. Like most SharePoint projects your requirements always change, and there’s always a need for further investigating the possibilities for how we can deliver quality solutions. In this article I’ve talked about some tips for how you can modify the NewForm and EditForm of your BCS External List by simply using a Custom Field Control. I’ve also talked about how you can deliver customized forms using jQuery as in the DispForm sample above.

    As a final note I’d like to shout out to Scot Hillier who is a fellow SharePoint MVP and author of the Professional Business Connectivity Services in SharePoint 2010 book for valuable tips and awesome discussions regarding this topic.

  • Author: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    If you’ve been working with BCS and external lists you may have noticed that there’s no RSS feeds enabled for those lists.

    So to get around this problem I’ve created a custom RSS feed generator that essentially provides you with an RSS/ATOM feed for you so you can render it in your browser or any feed-reader of choice.

    Please note that this is a beta with a few things that needs fixing before it should be used, I’d like your feedback on it so I can complete it for you all to utilize.

    External Lists and RSS

    If you go to your SharePoint 2010 installation where you’ve got an external list you will see that you’re lacking the RSS functionality on that specific list.

    Example:
    image

    The RSS feed is by default disabled, and out of the box there’s no way to enable it for this specific type of list.

    Some people gave me the brilliant idea of using REST and the ListData.svc service to pull out the data from the lists. But as you know (or will know from now on) is that REST and External Lists is a no go. You can’t utilize the ListData.svc service to pick out information from your external lists, unfortunately.

    A custom RSS generator for your external list

    I’ve created an RSS generator feature for your external lists, which (when enabled) will give you two new buttons in your External List ribbon menu called "Custom RSS".
    The first button will take you to the Feed, and the second button is there to enable you to toggle the settings for the feed (i.e. what fields to show in the feed etc). The second button is only available to administrators of that list. Pretty sweet.

    Custom RSS Ribbon tab with an RSS Button:
    image

    Custom RSS Feed Settings dialog:
    (The RSS fields title, author, pubDate and description can be mapped to any field in your External List)
    image

    Custom RSS Feed rendered in the browser:
    (Rendered based on settings done in the Settings-dialog)
    image

    Feed opened in the RSS reader in Outlook 2010

    image

    Download and Install the RSS generator

    Alright, so this is not a complete feature as of yet – there’s some glitches that is to be fixed and tuned, but I would love your feedback if you try it out. Please use the contact form and submit any feedback or features you’d like to see in this RSS gadget.

    You can download the current version (not for production) here:
    [BETA]Zimmergren.SP2010.BCS.RSS.wsp

    Author: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    I bumped into an issue the other week where I was creating a new BCS External Content Type and was hoping to hook up some new connections on a couple of demo farms I’ve created.

    While most of these things were working like a charm, I bumped into an odd error message that basically told me that the elevation of privileges isn’t enabled on my BCS Service Application.

    Problem, a short story told even shorter

    You might receive an error message like this when trying to hook up a new External Data Source depending on your configuration:

    The metadata object that has Name ‘yourName‘ has a Property with name ‘AuthenticationMode‘ and value ‘RevertToSelf‘. This value indicates that the runtime should revert to the identity of the application pool, but reverting to the application pool must be explicitly enabled for the service application by a farm administrator.

    Solution

    While digging around for a couple of minutes I couldn’t really find a suitable UI option for changing this behavior, so I dug into the power of PowerShell instead – which probably saved me quite some troubleshooting.

    First you need to check the name of your Business Data Connectivity Service Application – a quick way is to check the UI, or you could use a PowerShell Cmdlet or use the API. I’m just using the UI for easy access:

    image

    Next, launch a new SharePoint 2010 Management Shell console and type in the following lines of code. Note that the name of the Service App below, is a copy of the name you took above:

    $bcsServiceApp = Get-SPServiceApplication | where {$_ -match "Business Data Connectivity Service"}
    $bcsServiceApp.RevertToSelfAllowed = $true;
    $bcsServiceApp.Update();

    This should now execute nicely (if you’ve got the appropriate permissions) and you should be able to see the RevertToSelfAllowed property be changed to true:

    image

    If you now would try to hook up your connections again, you should hopefully not see this message again.

    Quick fix, done. Enjoy.

    Auhtor: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    Lately I’ve been rolling around parts of Sweden and doing training, seminars and workshops on SharePoint 2010 with a bunch of companies and people.

    One thing that I’ve been showing off, which I’m totally in love with by the way, is the BCS (Business Connectivity Services) functionality.

    I’ve been getting a few questions from people who have been trying this out, but stumbled onto some problems with it in terms of permissions when they tried it out themselves.

    Problem – Access Denied by Business Data Connectivity

    When you’ve created your external list and try to access it (even as the same user, Administrator, that created it) you might get the following error:

    image
    Access denied by Business Data Connectivity

    If you bump into this, please don’t freak out – just keep reading..

    Solution – Permissions on the BCS Entity

    To resolve this so called problem, follow along here:

    Go to Central Administration -> Application Management -> Manage Service Applications -> Business Data Connectivity Service* -> [Your Entity] -> Set Permissions

    * or whatever name you’ve chosen for your BCS Service application

    image

    Configure the actual permissions

    In my case below, I’ve just told SharePoint that my Farm Administrator should be able to do all actions (Edit, Execute, Selectable in Clients and Set Permissions)

    image

    Please note: You might want to use different permissions in your environments – the permissions set in this blog post is just to demonstrate how you effectively change/add permissions for your BCS Entities to get up and running.

    You will most likely be required to performa an IISRESET at this point to force SharePoint to understand what just happened :-)

    Check your external list

    You should now be able to access the external list and see the desired result.

    image

    Edit: As mentioned in the comments by David Parra, you can in some cases set “Metada ”Metadata Store Permissions” if the other attempts fail. Just remember to always do an IISRESET after you’ve set the permissions.

    Keep rocking folks!

    Cheers

    Author: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    Article 3 in the small BCS-series:

    1. SP 2010: Getting started with the Business Connectivity Services (BCS)
    2. SP 2010: Programmatically work with External Lists (BCS) in SharePoint 2010
    3. SP 2010: Programmatically work with External Lists (BCS) using the Client Object Model

    In my previous article in the series, I talked about how easy it is to fetch information using the standard SharePoint server API-approach. In this article I will talk about how you can access data in your BCS data source, by utilizing the Client Object Model.

    Client Object Model code to read from the external list

    Just like I described in my previous article, you now have the awesome ability to work with data in your External Lists (connected to a data source using BCS) – namely, you can use the standard SharePoint APIs.

    Since I’ve shown you how you can do this using the Server Object Model, I thought I could take another spin at it and show you the code for doing basically the same with the Client Object Model.

    The underlying data

    As with my previous article, I’m still using the same data source as I set up in my first article – the "ProductList" table in my SQL Server database called "Zimmergren_DB"

    As seen in the SQL Server Management Studio:
    image

    Let’s fetch the data using a Windows Forms application that utilizes the Client Object Model!

    I’ve designed a Windows Forms application to utilize the .NET Client Object model (in contrary to using the Silverlight client object model or JavaScript client object model).

    It looks like this:
     image

    When you click the fancy button called "Get External Data", it will use the Client Object Model to fetch the records from the external list (from the SQL server) and display them in a DataGridView. Nothing fancy.

    The code!

    With no further delays or chit-chat, here’s the simple code!

        // Define the Client Context (as defined in your textbox)
        SP.ClientContext context = new SP.ClientContext(tbSite.Text);
        SP.Web site = context.Web; 

        var ProductList = site.Lists.GetByTitle(tbList.Text); 

        SP.CamlQuery camlQueryAwesomeness = new SP.CamlQuery();  

        IQueryable<SP.ListItem> productItems =
                                          ProductList.GetItems(camlQueryAwesomeness); 

        IEnumerable<SP.ListItem> externalList =
                                          context.LoadQuery(productItems);

        // This is where we actually execute the request against the server!
        context.ExecuteQuery(); 

        // Retrieve the products from the product list using some fancy LINQ
        var productListData = from product in externalList
          select new
          {
              // We’re never pointing to the field at the 0-index
              // because it’s used by the BDC Identity itself. Hence our elements start at 1.
              ProductID = product.FieldValues.ElementAt(1).Value.ToString(),
              ProductName = product.FieldValues.ElementAt(2).Value.ToString(),
              ProductDescription = product.FieldValues.ElementAt(3).Value.ToString()
          }; 

        // Simply clear the rows and columns of the GridView
        gvProducts.Rows.Clear();
        gvProducts.Columns.Clear(); 

        // Add the columns we need (ProductID, Name, Description)
        gvProducts.Columns.Add("ProductID", "ProductID");
        gvProducts.Columns.Add("Name", "Product Name");
        gvProducts.Columns.Add("Description", "Product Description");
        foreach (var product in productListData)
        {
            // For each product in the list, add a new row to the GridView
            gvProducts.Rows.Add(
                                     product.ProductID,
                                     product.ProductName,
                                     product.ProductDescription
                                     );
        }

    References and recommended reading

    1. Getting Started with the Client Object Model in SharePoint 2010
    2. Getting Started with Business Connectivity Services in SharePoint 2010

    Summary & Download

    At this point, I’ve showed you three short articles in which I describe how you can set up a Business Connectivity Services data source – then utilize the Server OM or Client OM to fetch information from that external data storage.

    Worth to note is that this is still a Beta product, which of course means that it may differ in functionality and performance in comparison with the final (RTM) version of SharePoint 2010.

    Download the complete Visual Studio 2010 project here: [ Zimmergren.SP2010.ClientOM.BCS.zip ]

    Author: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    Article 2 in the small BCS-series:

    1. SP 2010: Getting started with the Business Connectivity Services (BCS)
    2. SP 2010: Programmatically work with External Lists (BCS) in SharePoint 2010
    3. SP 2010: Programmatically work with External Lists (BCS) using the Client Object Model

    In my previous article I talked about how you can set up a simple BCS configuration to fetch and work with external data in SharePoint 2010. In this article I will talk about how you can utilize the SharePoint 2010 object model to work with that external data, directly from the SharePoint API. It’s all really simple!

    Working with data in an External List using the SharePoint Object Model

    The code in this sample doesn’t really differ from the way you fetch information from any other list in SharePoint (2007 or 2010). This – of course – is very welcomed news, as we do not need to learn any new frameworks or tools to work with the data in our external lists. It simply works as any other SPList, basically.

    Retrieving external data, made simple:

    When fetching items from an external list, you can simply do that by utilizing the good-old SPList object. We do not need to work with any other types of namespaces or frameworks in order to do this.

    In my SQL Server I’ve got a table called “ProductList“.
    This list is filled with the following data:

    image

    Fetching some items from the external list, and displaying them in a console app:

    // Product List is my external list, that is working with data in the SQL Server!
    SPList list = web.Lists["Product List"];

    SPQuery q = new SPQuery();
    q.Query =
    “<Where><IsNotNull><FieldRef Name=’ProductID’ /></IsNotNull></Where>”;
    q.RowLimit = 100;

    SPListItemCollection col = list.GetItems(q);

    foreach (SPListItem item in col)
    Console.WriteLine(item["Name"].ToString());

    This will render the following result (fetched from the database):

    image

    The things you see in the console windows is fetched straight from the SQL Server (using a BCS connection through the External List).

    Writing data to the External List (hence, writing to the SQL Server)

    Seriously, this is way too easy as well…

    // Get the external list
    SPList list = web.Lists["Product List"];

    // Use the traditional approach to create SPListItems and hook it up with the list
    SPListItem item = list.Items.Add();
    item["Name"] = “Sample Product Wohoo“;
    item["Description"] = “Sample Description Wohoo“;
    item.Update();

    Upon running this code in your SharePoint application, it will create the SPListItem object and add a Name and Description. When you hit .Update() it will push this data through the data source connection, to your SQL server.

    Here’s what the updated data looks like:
    image

    We’re running a Beta-product!

    As you can imagine, there’s a ton of new cool things to work with in SharePoint 2010 – where the BCS is one. This article discuss the very basics of how you can retrieve information from these lists using the normal API-approach.

    At the time of this writing (during Public Beta) there isn’t any measures on performance and what impact it has on the server in comparison to alternative ways to fetch and work with the data.

    As time goes on, there will be probably be some new information on this – I’ll keep you posted when I know more.

    Summary

    As you can see, working with external data from the SharePoint API isn’t very hard to do. What you need to make sure is to have an external list set up somewhere (see this article for how you can do that) and then you can simply use the normal SPList object from the SharePoint object model to work with the external list and it’s external data from the SQL server (in my case).

    So if you haven’t already: Get on the SharePoint 2010 wagon and enjoy the ride!

    Author: Tobias Zimmergren
    http://www.zimmergren.net | http://www.tozit.com | @zimmergren

    Introduction

    Article 1 in the small BCS-series:

    1. SP 2010: Getting started with the Business Connectivity Services (BCS)
    2. SP 2010: Programmatically work with External Lists (BCS) in SharePoint 2010
    3. SP 2010: Programmatically work with External Lists (BCS) using the Client Object Model

    BCS in SharePoint 2010 is an awesome refinement of the Business Data Catalog from MOSS 2007. With BCS – or Business Connectivity Services – you get the possibility to connect external data and work with it from SharePoint.

    In this article I will not cover the basics of what BCS is all about (MSDN/TechNet does this very well) – I will rather give you a walkthrough of how you can setup a BCS connection to an external database, and then work with this information directly from a SharePoint list – without the user actually knowing anything about the connection to the database.

    BCS Poster: Business Connectivity Services Poster
    BCS Team Blog: http://blogs.msdn.com/bcs/

    A sample SQL database

    I’ll just show you how my sample database is set up – simply create a new database in your SQL Server and have it filled with some example data. In my case, this is the data in my SQL database, called Zimmergren_DB:
    image

    In this sample database, I’ve added a table called ProductList which in theory will represent some products in this database, like this:
    image

    I’m filling the database with some sample data, so we will be familiar with this data when we later watch this information from SharePoint:
    image

    Alright – we have some sample data in our SQL Server. Nothing fancy, just some very simple data. Great, let’s get going with the fun stuff!

    Creating an external content type

    The most effective and easy way to set up a simple BCS connection, is to use SharePoint Designer 2010. You heard me, we can now get up and running with BCS by using SPD instead of modeling complex ADF files and things like that.

    In order to do this, we need to create a new External Content Type!

    Here’s how do create our External Content Type and hook it up with our database, step by step:

    1. Open the site you want to work with using SharePoint Designer 2010
    2. Select "External Content Types" in the left hand navigation:
      image
      Loading this page might take some time, be patient!
    3. Click to create a new External Content Type like this:
      image
    4. Click the link that reads: "Click here to discover external data sources and define operations":
      image
    5. Click "Add Connection"
      image
    6. Select "SQL Server" as your Data Source Type:
      image
    7. Enter the details about your connection to your SQL Server:
      image
    8. When the connection is made, your Data Source Explorer will be filled with the database you have specified. Now choose the table you want to work with, and right-click and select "Create All Operations":
      image 

      You’ll be presented with a wizard-like dialog where you can specify the operations, elements and other properties for your BCS connection.

    9. Click "Next" to get to the Parameters page
    10. Select the field that you want to act as an Identifier. In my case I’ve selected my ProductID just to get on with it:
      image
    11. Click "Finish"
    12. You’ll be presented with a list of operations that your External Content Type can do, like this:
      image

    That’s it. A few points, a few clicks – and you’re done. Let’s create an external list (using the Browser to show how simple it is..) and hook up our external content type with it!

    Creating an external list

    There’s a few ways to create an external list in SharePoint 2010. We will create it using the Browser UI to show you how simple it can be.

    1. Open your site and choose Site Actions - More Options…
      image
    2. Select the External List template, and click Create
      image
    3. Enter a name for your list, e.g. Product List
    4. You’ll see a field in this list called External Content Type, click the browse-button beside it:
      image

      What is really awesome here, is that you’re now presented with a dialog where you simply can choose the data source for this list. That means, you’ll select the data source you’ve created (mine is called Zimmergren_DB). Then your list will automatically work against the SQL database, but still have the look and feel of a SharePoint 2010 list.

    5. Select your data source and click OK:
      image
    6. Now simply click the button called Create:
      image

    Would you look at that! You’re now working with external data, from your (what looks to be) normal SharePoint list! This is brilliant!

    You now have the ability to create new items, update existing items, delete items and do all your normal CRUD-operations (CRUD = Create, Read, Update, Delete) straight from the SharePoint 2010 list.

    Proof of concept – Adding a new product

    Let’s just for the fun of it add a new product called "Awesome Product 1.0" like the following screenshot:
    image

    Now go to your SQL Server and see the changes take effect immediately. The data is NOT stored in SharePoint, it’s stored in your SQL Database.

    This is what my table now looks like in the SQL Server, after adding a new item in the SharePoint list:
    image

    Summary

    With a few points, followed by a few clicks – you’ve set up your external data connection. Basically it’s that simple.

    Of course there’s a lot of things to consider when doing these configurations – and you might not want to auto-generate the CRUD-operations, but rather create them one by one and specify more fine-grained permissions etc.

    This is merely a sample to show you how easy it is to actually get up and running with the SharePoint 2010 Business Connectivity Services (BCS) and work with external data!

    Enjoy