Wednesday, July 21, 2010

Displaying Business Data List Web Part based on a Query String value.

Here I will demonstrate how to display the External Content data in a filtered (at the web service) list format based on a Query String value.

I would recommend you to read my previous blog, titled: “BDC/BCS integration using WCF Service” to get more clarity on the how I created the External content type.

Background: The External content is being serviced through Web Service integration of Business Connectivity Service.
Web Service Finder (Read List) Operation takes in a parameter called userName and returns a List collection.

It was straight forward to select Business Data List web part.
1. Go to a page where the Web Part is to be added.
2. Site Actions -> Edit Page ->
3. Select Edit Tools (Insert) -> Select some location on the canvas and Click on Web Part.
4. Category: Business Data -> Web Parts: Business Data List
5. Click on Add
6. Configure the Data List Web Part by clicking on OPEN THE TOOL PANE link.
7. On the Properties pane on the right hand side, Select the External Content Type and click on OK.

Things that made it more complicated was, I needed to display the list based on a filter that is dynamic and the UI should not have a filter to select from. Follow the steps below to get things working in the way it has to be.

I had defined a Filter while defining the External Content Type let's say the name of the filter used was filterParam: Comparison

Create another web part to service the Data List web part with a dynamic value (Say a query string)
1. Category: Filters -> Web Parts: Query String Filters
Note: This web part will not be visible to configure unless you click on the Edit Web Part of the Business Data List Web Part.
2. Click on the Open the Tool Pane of the Query String Filter Web Part.
3. Set the Filter Name and Query String Parameter Name as 'userName'.
4. Modify the Advanced filter if required to configure no query/multi value query.
5. Click OK.

Create an association between the Query String Filter Web Part and the Business Data List Web Part.
1. Click on the Connections (found below the Edit web part) of the Data List Web Part.
2. Get Query Values From -> Query String URL Filter.
3. This will show a pop up to select the External content type user parameter ('filterParam' filter as defined in the external content type) to which to associate the query string.
4. Select the parameter and click Finish.

Finally, Ensure you do a Save and Close on the Ribbon to save the added two web parts with its configurations.


Test the URL with different query string value
Ex: http://server:port/sites/teams/SitePages/Collegues.aspx?userName=Bob

It should work! If not then Bing it and find it. That's what I did :)

To hide the filters on the web part and also to use the My Profile property, as a filter, do the following.
1. Click on the Edit Web of the Data List Web Part.
2. You should see an 'Edit View' link on the web part.
3. You can use filters like User Profile Properties on which the External Content type will filter. i.e. will be passed as a parameter to the Web Service.
4. Disable the Allow user to change the criteria check box if you do not want to see the filters on the web part.

No comments:

Post a Comment