Lightning Tools Blog

SharePoint Tools, Web Parts and Discussions

Lightning Storm Forums for SharePoint – Feb 2010 release

We’ve just uploaded a new release of the Lightning Storm Forums. This has a couple of new features that have come directly from customer feedback:

Easier to delete topics

If you have the permissions to do so, you can now delete topics directly from within the topic view:

image

Previously you had to go into the forum management screens to delete an entire topic – now it is much easier.

Easier to sign up to alerts

When you create a new topic or reply you’ll have a checkbox that can allow you to sign up to be alerted of new posts:

image

Much easier now to setup alerts for topics you are interested in

Performance information available

If you think your forums are a little slow in loading, you can now select the option in the web part properties to see Debug Timing information

image

When viewing a topic, at the bottom you’ll now see information about how long each method call is taking. This makes it much easier for us to support you if you do have any performance problems.

 

You can download a Free Trial of the Lightning Storm Forums from it’s home page:

Lightning Storm Forums for SharePoint

 

If you are an existing customer login to the site and checkout the downloads area.

Oracle and the Business Connectivity Services

Previously we showed you in text how to connect the BCS to Oracle using BCS Meta Man:

Business Connectivity Service and Oracle with BCS Meta Man

Now we have a video to share with you! :-)

 

Hrayr will be auditioning for the role of Dr Evil in the next Austin Power movie! :-)

Creating Limit Filters in SharePoint Designer 2010

In this walk through we are going to show you how to create Limit Filters for your Business Connectivity Services External Content Types in SharePoint Designer 2010. These filters will let limit the amount of records being returned by your back end data source which will not only improve performance, but also make your users lives easier as they have less data to work with and process.

One important thing to note is that a Limit Filter on it’s own will just limit the items returned, this means that without another filter type you can only access a subset of your data. For example if you want to limit the amount of Products returned by a query to 100, you would add a Limit Filter and add another such as a Wildcard Filter, this will mean you will get a maximum of 100 Products which match the Wildcard filter returned. For information on how to add a Comparison or Wildcard Filter check out our blog post here: Creating Comparison and Wildcard filters for BCS in SharePoint Designer 2010

Pre-requisites..

  • SharePoint Designer 2010
  • A Data Source – We will be using the ‘AdventureWorks’ Products table

How to..

  1. Open SharePoint Designer
  2. Connect to your SharePoint Site
  3. Click on ‘External Content Types’ from the Site Objects list

    View External Content Types
  4. Click ‘External Content Type’ from the ‘New’ section of the ribbon
  5. Give your External Content Type a meaning full name – You just need to click on the existing text to edit

    Give your External Content Type a good name  --> External Content Type with the name set
  6. Click the link in the External Content Type Operations section to ‘discover external data sources and define operations’

    Add a new connection
  7. Click ‘Add Connection’ and choose ’SQL Server’
  8. Enter your connection credentials and click OK

    Enter the connection details
  9. Expand the tree view to show the ‘Products’ Table

    Expand to see your tables
  10. Right Click on the Table and choose ‘New Read List Operation’
  11. Change the ‘Operation Name’ and ‘Operation Display Name’ to “All Products and Information”, Click Next
  12. You will see that SharePoint Designer gives you a warning letting you know you should add a Limit Filer

    SharePoint Designer warns you about creating a Limit Filter
  13. On the ‘Filter Parameters Configuration’ screen click ‘Add Filter Parameter’

    Add a Filter Parameter  
  14. When the properties section display’s change the ‘Data Source Element’ to ProductID and click on ‘(Click to Add)’

     Map the Data Source Element
  15. Enter the Filter Information as the following. We are going to create a Limit Filter on the Product ID. A Limit Filter lets you choose the number of rows you want returned from the database

     Create Limit Filter
  16. Click ‘OK’
  17. Change the Default Value to 100 – 100 rows will be returned from the Database

    Set the default value
  18. *As per the note at the top of the page, normally you would add another Filter Type here*
  19. Click Finish
  20. Click ‘Save’

    Save the External Content Type
  21. The ECT will be saved to the BDC Metadata Store

    External Content Type will be saved to BDC Metadata Store
  22. Once the document has been saved we can navigate to our SharePoint Site
  23. Add a ‘Business Data List’ Web Part to your page

    Add Business Data List Web Part
  24. Click on the icon to bring up the ECT Picker
  25. Select the AdventureWorks Products ECT
  26. Click ‘OK’
  27. The web part will display the Product information, if you page through the results you will notice that it will only go to item 100.

    Paging of data is limited 

 

<phill/>

BCS Meta Man Alpha 2 released

As you may have seen from the content we have been posting up on the blog over the past 24 hours – BCS Meta Man Alpha 2 has been released. We’ve been working on this release for the past 8 weeks – it was supposed to be 6 but Christmas and New Year got in the way! :-)

Here are the new features available in this release:

Ability to upgrade MOSS 2007 BDC application definition files to SP2010 BCS models

Upscaling a BCS Model created in SharePoint Designer 2010 to a Dot Net Assembly project

Business Connectivity Service Models with Oracle

Creating BCS Actions in BCS Meta Man

and finally…

Creating BCS Filters using BCS Meta Man

We have screencasts of each area of new functionality that we’ll be posting up each day next week so make sure you are subscribed to our RSS feed!

 

Please download this free Alpha release from here:

BCS Meta Man Alpha Download

 

We’d love to hear your feedback on this release, what features we need to develop further, and how you are planning on using the BCS in SharePoint 2010. Feel free to email us at anytime at support@lightningtools.com to have a chat.

<nick/>

Create BCS Filters using BCS Meta Man

In this walkthrough we will demonstrate how to define BCS filters for BCS External Content Types in BCS Meta Man. As of BCS Meta Man alpha 2 (released 22nd Jan 2010) we support filters for SQL and Oracle. In this sample we will use SQL server, but you can use the same steps for Oracle and define filters for Oracle tables as well.

1) Open up Visual Studio 2010 and create a new empty SharePoint project.

Create an Empty SharePoint Project

2) Add a new BCS Meta Man item to your project.

Step2

3) When the BCS Meta Man diagram is open, in the menu bar click on BCS Meta Man-> BCS Meta Man Data Source Explorer

Open BCS Meta Man Data Source Explorer

4) When the Data Source Explorer is shown, click on the Add SQL Connection button.

Add SQL Connection

5) In the connection dialog, set the connection parameters to your SQL database. We use the AdventureWorks database for our walkthroughs.

Enter SQL Connection properties

6) If the connection is successful it will populate the explorer treeview with our databases that you can expand to show the tables available.

Data Source Explorer with tables

7) Drag and drop any two tables you want, in this walkthrough we use Employees and Product tables; we will define a comparison filter for the Product table and a Wildcard for Employee. Your diagram should look like this.

Create two External Content Types

8) Right click on the Employee table and choose Manage Entity.

Right click and choose Manage Entity

9) In the Entity Management dialog go to Methods tab and select the Finder method.

Go to Methods tab and select Finder method

10) Click on New button in the Filter section and configure a Wildcard filter for the Employee table’s Finder method. Click on Save button, and then Save the modifications.

Create a new Wildcard Filter

11) Using the above mentioned steps, define a Comparison filter for the Product table.

Create a new Comparison Filter

12) If you open the generated service c# classes, you’ll find that c# methods have been modified to accept input parameters that will be used to filter the data being returned

13) Rebuild the project and press CTRL+F5 to deploy the solution.

14) Go to your SharePoint site, and add two BCS List web parts. Set Employee as a type for one of them and Product as a type for the other BCS List web part.

Add 2 BCS List web parts to your page

15) Try to enter some filter values to display the records.

Configure and test your External Content Types with the filters

<hrayr/>

BCS Action created in BCS Meta Man

BDC Action are very powerful and popular in MOSS 2007. They allow you to link your Business Data to external urls such as Search Engines or other Enterprise Applications. In SharePoint 2010 you can define actions for BCS External Content Types and use them in BCS web parts the same way you do in MOSS 2007. You can get more information about BDC Actions from here

BDC Actions

SharePoint Designer 2010 and Visual Studio 2010 allow you to create BCS external content types. There is no support however to define BCS  within SharePoint Designer or Visual Studio 2010. If you want to define actions for a BCS external content type, you must deploy it to the BCS service and then open the Central Administration, navigate to BCS Service and define the BCS action there.

Create BCS action in SharePoint Central Admin

If you use BCS Meta Man to create a BCS External Content Types you can easily define BCS Action within Visual Studio 2010.

The steps below walk us through how to do it…this walk through presumes you have BCS Meta Man alpha 2 (or later) installed, you can download it from here:

BCS Meta Man Download.

1) Open Visual Studio 2010 and create new empty SharePoint project.

Create Empty SharePoint project

2) Right click on the project and select “Add New Item” and choose BCS Meta Man from the dialog.

Add BCS Meta Man project item

3) When this project item type is added to your project it will automatically add a new feature and open the BCS Meta Man designer. Now, from menu bar click on BCS Meta Man - > BCS Meta Man Data Source Explorer.

Open BCS Meta Man Data Explorer

4) In the data source explorer click on “Add SQL Connection” which will pop up new dialog, where you can set up the connection to your back end SQL database.

Set connection settings

5) When the connection is configured, it will populate the treeview with available databases and tables. In this walkthrough we have used the AdventureWorks database and Product table.

Drag table onto the design surface

6) Drag and drop the “Product” table to the designer and select the methods which you want to be generated by BCS Meta Man. Right click on the top of the entity and select “Manage Entity”.

Manage your BCS Entity

7) In the Entity Management Entity Tab, set the Title column for the External Content Type, so then we can use actions in the BCS Data list web part for each record. (see Step 11).

Step7a

Now click on the “Actions” tab and click on “Add Predefined Action”.

Entity Management screen

8) In “Action Picker” dialog choose any predefined action you like. In this walkthrough we have chosen “Bing”. You can create custom actions by clicking on the “Create Custom Action” button and setting the necessary parameters for a BCS Action.

Create pre defined BCS Action

9) After you have selected an action, it will fill up the BCS Action properties. You can change those properties, and add or remove action parameters.

Set BCS Action Properties

10) We need to make Bing search with the product’s Name, so we need to remove the ProductId Action parameter and add new one – Name.

Add new Action Parameter

11) When you click on the “Save” button of the entity management dialog it will add the Action to the BCS Model. Rebuild the project and press CTRL+F5 to deploy the solution. Navigate to your SharePoint site, add a BCS List web part and choose our Product External Content Type to be displayed. When data is populated you can find a dropdown on each record’s title column (Name in this example) and you can see available Actions there.

clip_image002[12]

12) When you click on “Bing” it will open search result page in new window. A Bing search query will be done by passing the Name parameter through from our BCS record.

clip_image004

<hrayr/>

Business Connectivity Services and Oracle with BCS Meta Man

In our previous blog posts we have already introduced to you how it is easy to create Business Connectivity Service External Content Types, upscale BDC application definition files and upsize SPD 2010 generated BCS models with BCS Meta Man. All these blog posts were done based off Microsoft SQL server. In this walkthrough we’ll show you how to create a BCS External Content Type, generate C# methods, and make an association for Oracle database tables.

1) Open up Visual Studio 2010 and create a new empty SharePoint project.

Create a empty SharePoint Project

2) Right click on the project and add a new BCS Meta Man item.

Add a new BCS Meta Man project item

3) Add System.Data.OracleClient reference to your project, which is in the following location,

C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.OracleClient.dll.

add System.Data.OracleClient.dll

4) When the BCS Meta Man design surface is in view you will find the BCS Meta Man menu item in the menu bar. Click on BCS Meta Man - > BCS Meta Man Data Source Explorer.

Open BCS Meta Man Data Explorer

5) Click on the “Add Oracle Connection” button of the data source explorer.

Add Oracle Connection

6) In the connection dialog, setup connection to your oracle database.

enter your Oracle connection details

7) If the connection is OK the treeview will populate with Oracle tables.

Treeview populates with Oracle tables

8) Drag and drop the Departments table to the design surface. In the Entity Creation wizard click on the Next button, select to generate all the methods and then click on the Generate button.

Drag and drop an Oracle table onto the design surface

9) BCS Meta Man will add new files to the project which contain generated C# code. You’ll also see the External Content Type on the design surface.

BCS Meta Man generates lots of code for you

10) At this point we have created a BCS external content type for Departments table. Please, do the same to create External Content Type for the Employees table too.

Department and Employee tables from Oracle

11) View the Visual Studio’s toolbox and choose the association action. Create an association between Departments(Source) and Employees(Destination) External Content Types. It will pop up a dialog for identifier mapping. Select DepartmentId in both dropdown boxes.

Set association fields between content types

12) Click on OK and it will create an association between those two tables. You’ll find that it automatically adds a new association method to the Employees External Content Type.

BCS Association created

13) Rebuild the project and press CTRL+F5 to deploy the solution.

14) Go to your SharePoint site and add a new External List. Set either Departments or Employees as the External Content Type to use for the list. We want to make sure, that all the generated methods work properly.

15) When the External List is displayed, it calls the BCS Finder method to populate the records.

BCS External List with Oracle data

16) Click on the Items ribbon which is in the top. If Creator method is configured properly then it should be enabled.

Create new item

17) Click on “New Item” and insert a record.

Add record to Oracle

18) You can see the inserted record in the list.

External List updated

19) Let’s check if the specific finder method works ok. Select any record in the list and go to Items ribbon. Click on View Item button.

Test Specific Finder method

20) “View Item” should execute the specific finder method.

View Item

21) And finally, let’s make sure that updater works properly. Select any item in the list, click on Items ribbon and then click on Edit Item button.

Check updater method

22) Update the name of the selected department and click on Save button.

Update data straight to Oracle

23) When the list is re populated, you’ll see the updated record.

External List updated live

Well, we have made sure that all the generated methods(Finder, Specific Finder, Creator, Updater) work properly, but we have an association between Departments and Employees as well. So, let’s make sure it works ok too.

24) Edit the page of your SharePoint site, add add a BCS List and BCS Related List web part. Set Departments as the type for BCS list web part and Employees as the type for BCS related list web part. Connect those two web parts, so BCS List web part should send data to the Related List web part. Select any department in the list web part. This will execute the association method and populate appropriate employees in the related list web part.

Test Oracle association works

<hrayr/>

Upscale a BCS Model created in SharePoint Designer 2010

SharePoint Designer 2010 is a great tool for putting together simple External Content Types, but often you will want to create your External Content Types in Visual Studio to give you the full power of c# code. Unfortunately with the BCS tooling that comes with Visual Studio there is no way to take a model built in SharePoint Designer 2010 and upscale it to a Dot Net Assembly based model. Using BCS Meta Man however you can do exactly this. BCS Meta Man will allow you to select your BCS Model built by SharePoint Designer and then generate all the c# methods and BCS model you need to be able to then take it further and customize it any way you like.

In this blog post we will show you how to create an External Content Type with SharePoint Designer 2010 and then upsize them with BCS Meta Man.

1) Open SharePoint Designer 2010 and click on Open Site.

Open SharePoint site

2) Enter your SharePoint site’s URL. In the left side you’ll see the navigation panel, select External Content Types.

Select External Content Type

3) At the top you can find the “External Content Type” button, click on it to create a new BCS External Content Type.

Create a new External Content Type

4) Set the Name, Display name(Departments) of your new External Content Type and click on the hyperlink to discover External Systems

Set ECT properties

5) When you click on the hyperlink, a new page will be opened to set up a connection to your back end database/WCF service or .Net assembly. Click on Add Connection button.

Add a new connection

6) Select SQL Server

SQL Server connection

7) Set parameters for the connection to your database. In our walkthroughs we use Adventure Works database. Click OK.

SQL Server connection properties

8) Expand the populated treeview, select the Departments, right click on it and select Create all operations.

Create all External Content Type operations

9) Click on Finish, so SharePoint Designer will create all the methods for your BCS External Content Type.

Complete ECT method creation

10) Press CTRL+S to save our Departments External Content Type

Save External Content Type

11) Please repeat the same steps and create another external content type for Employee table of the AdventureWorks database. Name it Employees.

Export External Content Types

12) Now we need to export these two external content types to XML file so that we can upscale them in BCS Meta Man. Select both external content types, right click on them and select Export Application Model.

Export our BCS Model

13) Set the Model Name.

Set Model Name

14) Set where our application model should be exported to.

set location to save our model

Now we have a BCS application model of Departments and Employees External Content Types. Next we need to upsize it in BCS Meta Man. BCS Meta Man will generate C# code for all the methods that you have defined in SharePoint Designer and also we will create an Association between them easily.

15) Open up Visual Studio 2010 and create a new empty SharePoint project.

Create empty SharePoint project

16) Right click on the the project and add a new BCS Meta Man item to the project.

Add a BCS Meta Man project item

17) When the project item is added, BCS Meta Man’s design surface is opened. Go to menu bar and select BCS Meta Man->Import SPD generated XML file.

Import SPD generated XML file

18) File open dialog will appear. Select the BCS application model we generated from SharePoint Designer

select the BCS Model to Open

19) BCS Meta Man will now create External Content Types for Departments and Employees ECTs that we created with SPD 2010. It will add new c# files to your project so you can modify c# methods that have been generated by BCS Meta Man for each BCS method

BCS Meta Man upscales our External Content Types

20) View the toolbox and create an association between those two External Content Types.

Create a BCS association

21) Rebuild the project and press CTRL+F5 to deploy the solution.

22) Open your SharePoint site, add BCS List and BCS Related List web parts to the page. Set Departments as a type for List web part, and Employees as a type for Related List web part. Connect those two web parts so List web part should send data to the related list web part. When everything is done you can select an item in Departments list web part and see associated data in related list web part.

Display BCS data in web parts

23) Now, let’s see if Creator and Updater methods have been upsized properly. Create a new External List in your SharePoint site and set Departments as a type for that list.

You’ll see that “New Item” and “Edit Item” buttons are enabled, which means BCS Meta Man has declared(upsized) those methods properly, try to insert and update some departments

New Item and Edit Item buttons are available

<hrayr/>

Upgrade BDC application definition files to BCS

BCS Meta Man alpha 2 has a great feature that allows you to upgrade MOSS 2007 BDC application definition file to SharePoint 2010 BCS models. BCS Meta Man will automatically read in the BDC XML and create the appropriate BCS Model, BCS External Content Types and generate the necessary C# methods.

In this blog post we will show you how to upscale a BDC application definition file with BCS Meta Man.

In the first part of this blog post, we will show you how to generate a BDC application definition file with BDC Meta Man and then we will show how to upscale that application definition file with BCS Meta Man.

1) Open BDC Meta Man and connect to SQL server, use AdventureWorks database.

Open BDC Meta Man

2) Drag and Drop Department and Employee tables to the design surface, and create an association between those two tables.

Create Entities on design surface

3) Set the output file path.

Set Output file path

4) Generate the application definition file.

Generate BDC application definition file

Now the BDC application definition file is generated we need to create a SharePoint project in Visual Studio 2010, add a BCS Meta Man project item and upscale the BDC application definition file.

5) Open up Visual Studio 2010 and create new Empty SharePoint project.

Create empty SharePoint project

6) Add a BCS Meta Man project item to your project. Right click on the project, choose Add new item and select BCS Meta Man item from the dialog.

Add BCS Meta Man project item

7) When the project item is added to your project, BCS Meta Man’s design surface will be opened automatically. From the menu bar select BCS Meta Man - >Import BDC Xml File.

Select Import BDC Xml File menu option

8) From the file open dialog, choose the BDC application definition file which you have already generated

Select the application definition file to upgrade

9) BCS Meta Man will generate BCS external content types, C# methods and required files. All this information has been imported to BCS Model generated by BCS Meta Man.

BCS Meta Man upgrades our BDC XML to a BCS Model

10) Now rebuild the project and press CTRL+F5 to deploy the solution.

11) Go to your SharePoint site and add BCS List web part and BCS Related List web part to your page. Set Department as a type for List web part and Employee as a type for Related List web part, connect those two web parts together.

If you select a department in the Department List it will populate employees from that department. We’ve successfully upgraded our BDC XML to a BCS model and deployed it!

Test the upgrade by deploying model

<hrayr/>

BCS Secure Store Services

This is our third look at Business Connectivity Authentication, you can check out our two earlier articles here:

Business Connectivity Services Authentication

Business Connectivity Services PassThrough and RevertToSelf

Secure Store Service

The Secure Store Service provides you with the ability to store many credentials in the form of User Name and Password, Tokens, Pins, or Strings. Within a Secure Service Application you will design the schema providing the required information to authenticate. Usually the minimum is username and password which might be two string fields or a Windows Username and Windows Password.

Within the Secure Store Application you map at user or group level the credentials that will be passed to the database. Using the Secure Store Service you can connect to the data source using Federated, Delegated or Impersonated Authentication. When connecting to the Line of Business System, the BCS runtime passes the mapped credentials from the Secure Store Service to the data source.

If you don’t already have a Secure Store Application, you will need to create one. This is done by going to Application Management in Central Administration and then Manage Service Applications. Within that screen you can create a new Secure Store Application as shown below.

Create new Secure Store Service

The Secure Store is storing highly sensitive data and therefore needs to be encrypted. Before you configure the application, it is a good idea to generate the key used to encrypt the contents of the store. The Encryption key should also be backed up.

Create encryption key

The Target application can then be created, allowing you to design the schema of the information passed to the data source.

details to pass to data source

more details to pass

Once you have created the application, you can Set Credentials using the drop down menu on the Application.

Set credentials to use for Secure Store Service

The final thing to do is configure you External Content Type to point to the Secure Store Target Application ID.

The Office Client applications can also make use of single sign on. They do this using an application called Credman and this has to be configured on the client machine itself. This allows users to store credentials themselves which will often require the assistance of Administrators to key in any service account passwords etc. However this does mean that Single Sign on can be used via SharePoint Workspace and Outlook etc.

Once you have Secure Store Service configured, within SharePoint Designer you will need to select ‘Connect with Impersonated Windows Identity’ and enter the Secure Store Application ID that you created earlier.

Set the Secure Store Service Application ID in SPD

If you are authenticated you will be able to connect to the data source using Secure Store Service.

One other type of Authentication supported is Claims based Federated Authentication. This allows WCF web services to pass credentials to a Secure Token Service which can be a SharePoint Secure Token Service or third party. You can then be authenticated based upon a claim against an identity. An example would be that you are authorised because you are older than 18 years of age, or that you have any other property value against a profile somewhere. A generated SAML token is then passed to the backend datasource. Federated Authentication will be covered in more detail in a future post.

<brett/>

BCS Creator and Updater methods for Dot Net Assembly

In our previous blog posts we have created BCS Model with Microsoft Visual Studio 2010 and have shown how to define Finder, Specific Finder and ID Enumerator methods for our Department Entity:

BCS model in Visual Studio 2010 – SpecificFinder and IdEnumerator

In this blog post we’ll extend our BCS Model and explain how to define Creator and Updater methods for Department Entity which will allow users to edit/insert records to the Department Entity.

First we are going to define our Creator method.

1) Right click on the Methods section of the Department Entity and choose “Add New Method”.

Add new BCS method

2) Give the method a name of “AddDepartment”.

Set name of BCS method

Next, we should create parameters for the Creator method. You should define all the fields that you want to see in the “New Item” dialog as Input parameters for the Creator method. The method also needs a return parameter which should be a structure which will contain information about the identifier(s) of the Department Entity.

3) Select Add Department method in Department entity and add new parameter in Bdc Method Details window.

Create input parameter

4) In this example we will create three parameters with “In” direction and name them “Name”, “GroupName” , ”DepartmentId”.

Name the parameters

5) Next we need to modify the properties of the type descriptors of each parameter. In BDC Explorer window expand the tree until you get to the type descriptors of the parameters.

Set property values of parameters

You should set the following properties to the type descriptors.

DepartmentID:

Name: DepartmentId

TypeName: System.Int16

Identifier: DepartmentId

GroupName:

Name: GroupName

TypeName: System.String

CreatorField:true

Name:

Name: Name

TypeName: System.String

CreatorField: true

6) Now we need to define the return parameter for the “AddDepartment” method. The return parameter should be a structure which will describe the identifier of the Department entity.

Open DepartmentService.cs class that we used in our previous blog posts to add C# code, and add the following class just under the Service class.

public class DepartmentSimple
{
    public short DepartmentId
    {
        get;
        set;

    }

}

7) Open Bdc Methods Explorer window and create new “Return” parameter for the AddDepartment method and name it “returnParameter”.

create return BCS parameter

8) Open the BDC explorer window, navigate to returnParameter of the AddDepartment method and change the type descriptor’s properties.

Name: DepartmentSimple

Type Name: BdcModelProject2.BdcModel1.DepartmentSimple,BdcModel1

9) Right click on the DepartmentSimple type descriptor and select “Add Type Descriptor”. Set the following properties.

Name: DepartmentId

TypeName: System.Int16

Identifier: DepartmentId

10) Here is how the parameters and type descriptors should be declared.

parameters and typedescriptors

11) Next, we need to create a Method Instance for the AddDepartment method. Open the Bdc Method Details window, select AddDepartment method and create a new method instance. Set the properties as has been done in the screenshot below:

create MethodInstance

12) Open DepartmentService.cs file and you’ll find there an AddDepartment method generated for you.

Replace the body of that method with the following code.

DataClasses1DataContext db = new DataClasses1DataContext("server=localhost;database=adventureworks2000;uid=***;pwd=***"); BdcModelProject2.Department createdEntity = new BdcModelProject2.Department
{
    DepartmentID = DepartmentId,
    Name = Name,
    GroupName = GroupName,
    ModifiedDate = DateTime.Now,
    rowguid = System.Guid.NewGuid(),

};

db.Departments.InsertOnSubmit(createdEntity);

db.SubmitChanges();

DepartmentSimple IdentifiersStruct = new DepartmentSimple
{
    DepartmentId = DepartmentId,
};

return IdentifiersStruct;

13) Rebuild the project and press CTRL+F5 to redeploy it. Open your SharePoint site and create a new external list on this BCS External Content Type. Select the “Items” ribbon on the top and you’ll see that “New Item” button is enabled which means that we have declared Creator method in BCS model properly, otherwise it will be disabled.

View BCS data

14) Click on “New Item” and it will show you the form to insert your data. In step 5 we declare input parameters and set CreatorField=true only for Name and GroupName, for that reason in this form we see only the Name and GroupName fields. If you need to add new fields, you need to declare them as input parameters and set Creator Field to true. For the Department table, DepartmentId is auto incremental PK, for that reason we didn’t set it as Creator field, but if your PK is not auto incremental then you need to define it as a Creator field as well.

Click on Save button in this form.

create new item

15) Here is the result.

insert result

Now, let’s create our BCS Updater method for our Department entity.

16) Right click on the Methods section of the Department entity and select “Add New Method”.

add new BCS method

17) Give our new method a name of “UpdateDepartment”.

give BCS method a name

We need to create input parameters for updater method.

18) In Bdc Method explorer window choose UpdateDepartment method and add new “In” parameter.

create new BCS parameter

19) Open Bdc Explorer window , expand the tree and navigate to this parameter. Choose the type descriptor and change the properties.

Name: Department

Type Name: BdcModelProject2.BdcModel1.Department,BdcModel1

20) Right click on Department type descriptor and add two type descriptors with the following properties.

DepartmentID:

Name: DepartmentId

TypeName: System.Int16

Identifier: DepartmentId

UpdaterField:true

GroupName:

Name: GroupName

TypeName: System.String

UpdaterField:true

Name:

Name: Name

TypeName: System.String

UpdaterField: true

NOTE: In this blog post we use Department table, and its PK field is set as auto incremental. To get updater method executed properly, we need to declare DepartmentId as Read Only in our Specific finder method’s return parameter.

21) Parameter and type descriptors should be looked like this. If you want to update more fields you need to add them as type descriptors set UpdaterField=true, as it is shown in step 21.

set the updater parameters

22) We need to create a method instance for UpdateDepartment method. In Bdc Method explorer window choose UpdateDepartment , add new method instance and set method instance type to Updater.

create a MethodInstance for our Updater

23) Open DepartmentService.cs and you’ll find there UpdateDepartment method generated for you.

Replace the body with the following C# code.

DataClasses1DataContext db = new DataClasses1DataContext("server=localhost;database=adventureworks2000;uid=***;pwd=***"); BdcModelProject2.Department updatedEntity = (from entity in db.Departments
                                                          where entity.DepartmentID == parameter.DepartmentId
                                                          select entity).FirstOrDefault();

updatedEntity.Name = parameter.Name;
updatedEntity.GroupName = parameter.GroupName;
dcontext.SubmitChanges();

24) Rebuild the project, click CTRL+F5 to redeploy, go to the External List that we have already created in step 14, select any record and you’ll see that “Edit Item” button is enabled, so we are allowed to edit the record cause we configure updater method in BCS Model properly.

Edit our data

25) Click on “Edit Item” and you’ll see Name and GroupName fields, which you can update. Change the GroupName and click on Save button.

save any update made

26) Here you can see the updated result.

results of our update method executing

Hopefully you found this post useful – in my next blog post I will be showing you how to create a BCS association between two External Content Types in Visual Studio 2010.

<hrayr/>

Creating Comparison and Wildcard Filters for BCS in SharePoint Designer 2010

In this walk through we are going to show you how to create Comparison and Wildcard Filters a Business Connectivity Services External Content Type in SharePoint Designer 2010. These filters will let you narrow down the amount of records being returned by your back end data source which will not only improve performance, but also make your users lives easier as they have less data to work with and process.

Pre-requisites..

  • SharePoint Designer 2010
  • A Data Source – We will be using the ‘AdventureWorks’ Products table

How to..

  1. Open SharePoint Designer 2010
  2. Connect to your SharePoint Site
  3. Click on ‘External Content Types’ from the Site Objects list

    image
  4. Click ‘External Content Type’ (ECT) from the ‘New’ section of the ribbon
  5. Give your ECT a meaning full name – You just need to click on the existing text to edit

    image  --> image
  6. Click the link in the External Content Type Operations section to ‘discover external data sources and define operations’

    image
  7. Click ‘Add Connection’ and choose ’SQL Server’
  8. Enter your connection credentials and click OK

    image
  9. Expand the tree view to show the ‘Products’ Table

    image
  10. Right Click on the Table and choose ‘New Read List Operation’
  11. Change the ‘Operation Name’ and ‘Operation Display Name’ to “All Products and Information”, Click Next
  12. On the ‘Filter Parameters Configuration’ screen click ‘Add Filter Parameter’

    image  
  13. When the properties section display’s change the ‘Data Source Element’ to Name and click on ‘(Click to Add)’

    image
  14. Enter the Filter Information as the following. We are going to create a Wildcard Filter on the Product name. A Wildcard Filter gives the search options of
    Starts With, Ends With, Contains and Equals so it will suit us searching for a product by name

    image
  15. Click ‘OK’
  16. Change the Default Value to *
  17. Click ‘Add Filter Parameter’ again, this time we will leave it to filter on the Product ID. Click the ‘(Click to Add)’ hyperlink
  18. Give the Filter a name – such as Product ID, click ‘OK’. We do not need to change anything else as by default the filter it will give us is a Comparison Filter with an Equals Operator

    image
  19. Click ‘OK’
  20. Change the Operator to ‘OR’
  21. Click Finish
  22. Click ‘Save’

    10
  23. The ECT will be saved to the BDC Metadata Store

    11
  24. Once the document has been saved we can navigate to our SharePoint Site
  25. Add a ‘Business Data List’ Web Part to your page

    12
  26. Click on the icon to bring up the ECT Picker
  27. Select the AdventureWorks Products ECT
  28. Click ‘OK’
  29. The Web Part will display the filter options

    image
  30. Enter a Value i.e Bike and press ‘Retrieve Data’ – This will bring back all products with the word ‘Bike’ in them

    image
  31. Take note of one of the Product IDs, Change the filter to ‘Product ID’ and enter the ID and press ‘Retrieve Data’ – this will bring back the matching Product

     image

<phill/>

Business Connectivity Services PassThrough & RevertToSelf

As a continuation from the post ‘Business Connectivity Services Authentication’, this post will explain how to setup PassThrough and RevertToSelf authentication modes within SharePoint Designer 2010.

When you are creating a connection to a datasource within SharePoint Designer 2010, you are presented with a choice of authentication modes including Users Identity, Impersonate Windows Identity, and Impersonate Custom Identity. These choices are explained below.

Users Identity

Connecting with the User’s Identity is referring to what used to be known as PassThrough authentication in BDC. This means that the Windows Authenticated user security token will be passed from the browser to IIS, and then SQL. This works well in Development environment for reasons described in the first post regarding the Double Hop Issue.

Impersonated Windows Identity

These two options are referring to the Secure Store Service (SSS) which will be explained fully tomorrow. SSS allows you to connect through Windows users or Custom such as a Federated SAML user account.

RevertToSelf

One of the options that you will not see in the above dialog box is ‘RevertToSelf’. To configure RevertToSelf, firstly select ‘Connect with User’s Identity’ and then choose ok. Once the connection is established, Edit the Connection Properties and choose ‘BDC Identity’ as shown below.

clip_image002

Note: The Above screenshot was taken from SharePoint Designer 2010 Beta 2 and this may have changed by the time the product is released.

There is no real configuration required to connect using User’s Identity (PassThrough) or RevertToSelf (BDC Identity) other than to ensure that all of the required users have permission to read and write to the data source. To configure SSS, you have to complete quite a few extra steps.

In our next post we will be describing how to configure Secure Store Service (SSS) in SharePoint 2010.

Business Connectivity Services Authentication

Business Connectivity Services is the new SharePoint 2010 replacement for the Business Data Catalog (BDC) which was introduced with Microsoft Office SharePoint Server 2007 Enterprise. Business Connectivity Services provides many improvements over the BDC including the ability to write back to the data source, offline capabilities through the office suite such as SharePoint Workspace, improved tooling and additional features such as External Lists. Our site provides several articles introducing the BCS which can be found here:

Business Connectivity Services Introduction 

Within this article we are going to explore how Business Connectivity Services Authentication works and how to configure it successfully, some of the issues that you will face and how to overcome or work around them.

There are two types of authentication to consider when it comes to authenticating with their backend data sources; User Identity or Impersonation. User Identity is where you use the identity of the logged on user, and want to pass those credentials through to the data source, and return data to SharePoint that the user should be allowed to see based upon the identity of the user. Impersonation allows the user to log on with their credentials, but connect to the data source as an alternate user, thus impersonating another user. Both of these options have pro’s and con’s.

It is a very common requirement for companies to wish for the User Identity to be passed through to the data source. This often works well in a development environment but fails when you move to production. The reason for that is something known as the Double Hop Issue. The Double Hop issue existed with the BDC and still exists with Business Connectivity Services. The reason being is that it is a Browser/IIS issue and not a SharePoint issue. When you connect to the data source using PassThrough authentication, the security token for the Windows Authenticated user can only be passed one hop. That one hop is from the browser to IIS. In a development environment, it is common for the database server to be installed on the same physical machine as IIS, and therefore the one hop is all that is required. However, in production it is rare to have the database server on the same machine and therefore two hops are required to pass the credentials from the browser to IIS to SQL. The user is therefore not authenticated.

One workaround for the Double Hop Issue while still maintaining the users identity is to configure your Environment to use Kerberos. Kerberos is difficult to configure and if it hasn’t been configured as part of the current architecture, it is difficult to get the go ahead from your administrators to all of a sudden change the authentication protocol that you use for SharePoint. Kerberos overcomes the double hop issue by allowing you to setup trusts between each server. E.g. a trust between IIS and SQL. The passing of credentials is then renewed at the IIS server.

If passing through the user’s identity is not important to you, then you can use Impersonation to overcome the double hop issue and still be authenticated at the data source. One of the options of Business Connectivity Services authentication is the ‘RevertToSelf’ option. RevertToSelf doesn’t use the Users Identity but instead uses the Process Account (Account that the BCS Runtime service is running with). This means that every SharePoint user regardless of their identity will connect to the data source as the same user. This sounds like a security issue, but actually works very well, since you can assign permissions to each user or group at the SharePoint level. You can assign permissions such as execute and write back. This is actually a good practice; since you have the option to revisit the permissions assigned to each Table, View, and Stored Procedure in SQL and assign it directly to the SharePoint user account.

Another method that Business Connectivity Services Authentication supports is the Secure Store Services (SSS). Secure Store Services is the replacement for Single Sign On (SSO) within SharePoint 2007. SSS provides you with the option to store credentials in a Secure Store Database which resides on the SharePoint Server. Credentials are then mapped to either from ‘user to user’ or ‘Domain Group to user’. This allows the credentials to be renewed again at the SharePoint server. SSS will be discussed in a blog post later this week.

We cannot really recommend one Business Connectivity Services authentication mechanism over the other as every organization has different configurations and political or environmental issues can sometimes dictate the choice.

Connecting to SQL Server using SharePoint Designer provides you with the following options for Authentication:

· Connect with User’s Identity

· Connect with Impersonated Windows Identity

· Connect with Impersonated Custom Identity

clip_image001

This post introduces the types of Business Connectivity Services authentication to consider. We will cover each type of authentication in detail over the next few days.

<brett/>

Business Data Catalog – writing back to ODBC

In the latest version of BDC Meta Man – 4.0.0.7, we included the functionality to allow you to write back to ODBC data sources that you connect to via an ODBC connection string such as DB2 or MySQL. Dmitry has just written a support article that shows you the steps how to do this:

BDC Write Back for ODBC Data Sources

<nick/>

SPD External Content Type from WCF

In this walkthrough we will create an External Content Type in SharePoint Designer based off a WCF services. Please follow the below steps to accomplish that.

1, Make sure your WCF services is hosted and is available to use. For this walkthrough we have used BDC Web Man to generate the WCF service for the Contacts table in AdventureWorks2000 database. BDC Web Man is a tool that can save you a lot of time as it generates all the c# code your WCF service will need in a way that the BCS can easily use. As of writing BDC Web Man only generates the Finder, Specific Finder, ID Enumerator and Association methods, so if you want to create more BCS Methods (e.g. Creator or Updater), you should add the appropriate web methods manually. For more information about the BDC Web Man, please visit http://lightningtools.com/bdc-web-man/default.aspx .

Open your IIS manager, navigate to the site which hosts your WCF service, and make sure it is running.

WCFIIS 

[please click the images for a larger view]

2, Open Internet Explorer and navigate to the .svc file. You should see appropriate page which shows that the WCF service is working.

WCFRun

So, now we are sure that our WCF service is hosted and runs OK. Now we can create our External Content Type in SPD based off this WCF service.

3, Open up SharePoint Designer 2010 and click the big button to ‘Open Site’

Step3

4, Enter the URL of your SharePoint site and press enter. SharePoint Designer will now connect and bring back the relevant information about that site. Below you can see the nice site Dashboard view that gives you a quick overview of your SharePoint site

Step4

5, Down the left side menu you’ll see the various SharePoint objects you can work with via SharePoint Designer, and the new object type we are interested in is External Content Types. When you click this menu item you’ll get a view of the other External Content Types deployed and also the Ribbon menu at the top of SharePoint Designer will change to reflect the work we can do with it.

6, In the Ribbon, click to create a new External Content Type

NewECT

7, Upon clicking this button you’ll be presented with the screen to edit and manage your External Content Type.

Step7

There are a number of labels that look like Hyperlinks that you can click to set their value. The first two are Name and Display Name. Set these values to be:

Name: Contacts
Display Name: Contacts

The Office Item Type will allow you to map your External Content Type to commonly used Microsoft Office objects such as Contacts or Calendar events. We’ll have a blog post on how to utilize these shortly.

For now we just need to choose an external data source to connect to. Click on the link ‘Click here to discover external data sources and define operations’

8, Clicking the link above opens up the Operation Designer view. Click on the button to Add Connection

Step8

9, Choose the data source type to be WCF Service and click on OK button.

DS

10, The WCF connection window will open. Here we need to apply information about our WCF service, so SharePoint Designer can connect to it.

In step 2, there is a screenshot and in red rectangle you can find out the URL which needs to be used as MetaData URL in the WCF connection window. In this walkthrough we used the following URLs for MetaData and Enpoint configuration.

Metadata URL: http://win-74y1750o0mq:4445/Service.svc?wsdl

EndPoint URK: http://win-74y1750o0mq:4445/Service.svc

WCFSettings 

11, When the WCF connection is configured you can click on OK button and it will try to connect to your WCF service. If everything is ok, then it will show you the available web methods.

WebMethods

12, When Web methods are populated, we should create appropriate BCS operations. In our example, we will use GetContactFinder as “Read List” operation, and GetContactsSpecificFinder as “Read Item” operation.

13, Right click on GetContactFinder and choose “New Read List” operation.

WCFFinder

14, Upon selecting the operation our WCF method is the Operation Properties window will open. In “Return Parameters” section you will notice the error message that “At least one identifier should be specified”. Choose “ContactID” and in the right panel tick the checkbox “Map To Identifier”. In Identifier combo box select the “ContactID”. Click on Finish button and “Read List” operation will be created.

WCFRetParamConfig

15, Right click on GetContactsSpecificFinder and choose “New Read Item” operation.

WCFSpecific

16, In Operation Properties window, in the “Input Parameters” section we need to map the input parameter to the identifier. Select contactid and in the right panel tick the checkbox “Map to Identifier” and select the ContactID from the Identifier combo box. Click on the Next button.

WCFInput

17, The Return Parameters section also contains an error messages regarding the identifier mapping. To fix these errors, in the left panel choose “ContactID” and in the right panel tick the “Map to Identifier” checkbox and select the “ContactID” in the Identifier combo box. Click on Finish button.

WCFSpecificRet

18, Now, at the right hand side of your External Content Type screen you can see the operations that we have defined. You can add other operations as well, e.g. Creator,Updater,etc.

WCFBCSMethods

19, Press “CTRL+S” to save the External Content Type.

WCFECT

20, We can open SharePoint and create External List on Contacts external content type.

WCFList

21, It will call the “Read List”(Finder) WCF method and populate the records.

WCFListFinder

22, Select any item and click on “View Item” ribbon, it will call “Read Item”(Specific Finder) method and view the selected item in new dialog.

WCFSpecList

ListSpec

 

If you have any questions about this walk through please feel free to leave a comment or email support@lightningtools.com

<hrayr/> 

BCS Multiple Finder Methods for External Content Types

One issue with the Business Data Catalog was that you could only define one Finder method per Entity. This meant that if you wanted to use two different SQL Views that each returned different columns from a table you would have to actually create two completely different entities.

With Business Connectivity Services you can now define multiple Finder methods, and then pick within the UI or object model which method to use. In this walk through we show you how to use SharePoint Designer 2010 and the BCS to define multiple Finder methods for your External Content Types.

Pre-requisites..

  • SharePoint Designer 2010
  • A Data Source – We will be using the AdventureWorks2000 Products table

How to..

  1. Open SharePoint Designer 2010
  2. Connect to your SharePoint Site
  3. Click on ‘External Content Types’ from the Site Objects list

     1
  4. Click ‘External Content Type’ (ECT) from the ‘New’ section of the ribbon
  5. Give your ECT a meaning full name – You just need to click on the existing text to edit

    2   --> 3
  6. Click the link in the External Content Type Operations section to ‘discover external data sources and define operations’

     4
  7. Click ‘Add Connection’ and choose ’SQL Server’
  8. Enter your connection credentials and click OK

     5
  9. Expand the tree view to show the ‘Products’ Table

     6
  10. Right Click on the Table and choose ‘New Read List Operation’
  11. Change the ‘Operation Name’ and ‘Operation Display Name’ to “All Products and Information”, Click Next
  12. We are going to ignore the filter for now (you should usually add a filter when you are returning a large data set), click Next
  13. Click ‘Finish’ on the ‘Return Parameter Configuration’ screen
  14. We have now created a ‘Read List’ \ Finder method which returns all items from our Products table with all of the columns

    7  
  15. Right Click on the Table and choose ‘New Read List Operation’ again
  16. Change the ‘Operation Name’ and ‘Operation Display Name’ to “All Product Names”, Click Next
  17. Ignore the filter screen again – Click Next
  18. On the ‘Return Parameter Configuration’ screen uncheck all of the ‘Data Source Elements’ apart from ‘ProductID’ and ‘Name’

    8  
  19. Click ‘Finish’
  20. We now have our two ‘Finder’ methods defined

    9  
  21. Click ‘Save’

     10
  22. The ECT will be saved to the BDC Metadata Store

    11  
  23. Once the document has been saved we can navigate to our SharePoint Site
  24. Add a ‘Business Data List’ Web Part to your page

     12
  25. Click on the icon to bring up the ECT Picker
  26. Select the AdventureWorks Products ECT
  27. Click ‘OK’
  28. In the View section you have the 2 Finder methods that we created, the ‘All Products and Information’ and the ‘All Product Names’

    14
  29. Select the default option of ‘All Products and Information’
  30. Click ‘'OK’
  31. All Products and Information are returned

    15  
  32. Click to edit the Web Part again
  33. Choose the ‘All Product Names’ View
  34. Click OK
  35. All the Product Names are now returned

    16   

<phill/>

BDC Meta Man 4.0.0.7 Released Yesterday

Yesterday we released a new version of BDC Meta Man.
The previous developer license of BDC Meta Man expires on 1/1/2010, but for version 4.0.0.7 we have extended this to 1/1/2011.
We’ve also added a few new important features such as the ability to modify identifiers on an entity:

http://www.lightningtools.com/bdc-meta-man/bdc-composite-key.aspx

And the ability to copy and paste SQL queries to create BDC methods:

http://www.lightningtools.com/bdc-meta-man/bdc-sql-query.aspx

You can download the latest release of BDC Meta Man from it’s homepage:

http://www.lightningtools.com/bdc-meta-man/default.aspx

SPTechCon Feb 10th-12th

Lightning Tools is proud to be a sponsor early next year of SPTechCon in San Francisco.  If you haven't seen SharePoint 2010 yet, SPTechCon will certainly provide you with excellent SP2010 technical content.  Lightning Tools is a silver sponsor at SPTechCon and will be able to demonstrate both the current SharePoint 2007 product range as well as some of our new SP2010 products including BCS Meta Man.

Brett Lonsdale will be presenting a session on The Business Data Catalog and Office Business Applications which will demonstrate some of the things you can do with the BDC that you perhaps hadn't considered such as populating content controls in Word, Outlook forms, and customizing the ribbon to lookup line of business data.

You can sign up for SPTechCon at the following site: www.sptechcon.com and follow sptechcon on twitter: www.twitter.com/sptechcon

BCS Webinar Slides

Many thanks to everybody who attended our Introduction to Business Connectivity Services Webinar yesterday. Unfortunately the Live Meeting recording didn’t come out very well so we’ve placed that in the Recycle Bin, but as promised here are the slides from the session:

Download the BCS Webinar slides

We’ll be re-running the session in the new year so if you missed it or want your colleagues to attend please keep an eye on this blog for the next date.

Thanks

<nick/>