Category: BCS

SharePoint Workspace cannot take a BCS list offline

Today I installed a BCS solution to a SharePoint 2010 farm. I wanted to take the list offline. So I clicked on the SPW button in the ribbon.

image

As expected, SharePoint Workspace popped open, and tried to get the list. But all I got was an message, that there was an error installing the list.

The eventlog, of the client I was working on, revealed that there was an error installing the solution (And we need the solution, to get the data on our clients. BCS uses solution which are deployed to clients as click-once applications to sync data.). The error details showed something like “Solution Install Stage:PendingDownload Solution Install Error”,the EventId was 2012 and the Datasource “Business Connectivity Services”. Not really a helpful message.

So I went to the SharePoint server and took a close look at the ULS log. And voilà, there was the answer: “External lists can only be synchronized with your computer from Microsoft SharePoint Server 2010 with Enterprise Client Access License features enabled. For more information, contact your system administrator.”

You need to activate enterprise features in order to use SharePoint Workspace with BCS data.

image

Lessen learned…

Oh. Don’t forget to switch on the Offline Synchronization feature for External Lists!

image

Using a custom field type in a BCS model

The BCS Team (Business Connectivity Services) wrote an blog post about using complex formatting and custom field types within your BCS model. Obviously this post was the source for the SDK article.

The example shows that you can use a custom field type to render data from external data sources this way:

<TypeDescriptor TypeName="Customer.Address" Name="CustomerAddress" DefaultDisplayName="Customer Address"> 
   <Properties> 
       <Property Name="SPCustomFieldType" Type="Customer.Address">Customer Address</Property> 
   </Properties> 
</TypeDescriptor> 

Well, to help you map this example to your data, I’ll write some more about the SPCustomFieldType property of the BCS model.

This is how a method would look like, if you want to map a column to a custom field type:

<Method Name="ReadItem">
  <Parameters>
    <Parameter Name="address" Direction="Return">
      <TypeDescriptor Name="Address" TypeName="RH.SharePoint.BCS.Address, BCSModel">
        <TypeDescriptors>
          <TypeDescriptor Name="Id" IdentifierName="Id" TypeName="System.Int32" />
          <TypeDescriptor Name="Street" TypeName="System.String" />
          <TypeDescriptor Name="Number" TypeName="System.String" />
          <TypeDescriptor Name="PostalCode" TypeName="System.String" />
          <TypeDescriptor Name="City" TypeName="System.String" />
          <TypeDescriptor Name="GeoCoordinates" TypeName="System.String">
            <Properties>
              <Property Name="SPCustomFieldType" Type="System.String">GeoCoordinates</Property>
            </Properties>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
    <Parameter Name="id" Direction="In">
      <TypeDescriptor Name="Id" TypeName="System.Int32" IdentifierEntityName="Address" IdentifierEntityNamespace="RH.SharePoint.BCS.Model" IdentifierName="Id" />
    </Parameter>
  </Parameters>
  <MethodInstances>
    <MethodInstance Name="ReadItem" Type="SpecificFinder" ReturnParameterName="address" ReturnTypeDescriptorPath="Address" />
  </MethodInstances>
</Method>

“GeoCoordinates” is the name of my custom field type, specified by <Field Name="TypeName">GeoCoordinates</Field>.

The data source for this BCS model is a LINQ to SQL class, where I’ve implemented a property to concatenate the latitude and longitude which are stored in the backend system.

public string GeoCoordinates
{
  get
  {
    if (Latitude == null || Longitude == null) return null;
    return string.Format("{0};{1}", Latitude, Longitude);
  }
}