Condividi tramite


How to: Add a Comparison Filter to a Method Instance That Returns Data

Applies to: SharePoint Server 2010

A Comparison filter limits the instances returned to those where the condition is met. SQL supports it with the WHERE clause. You would typically define a Comparison filter on a SpecificFinder method or a Finder method instance.

In this topic, let’s add a Comparison filter called StateFilter to the Contact external content type’s Finder method instance.

Prerequisites

  • Microsoft SQL Server 2005 or later installed on the server running SharePoint Server.

  • The AdventureWorks 2008 database installed on the server running SharePoint Server.

  • The Contact External Content Type has been created based on the AdventureWorks database. For more information, see How to: Create External Content Types.

Adding a Filter to a Method Instance Using SharePoint Designer

  1. Launch Microsoft SharePoint Designer 2010, and then open the SharePoint site that contains the external content type.

  2. In SharePoint Designer 2010, click External Content Types on the left navigation. This displays all external content types that are defined in that site’s service application’s Business Data Connectivity (BDC) servicemetadata store. Select the Contact external content type.

  3. Click the Contact Finder operation to add a filter. This displays the Parameter Configuration wizard.

  4. Click Filter Parameters. In the Filter Parameters wizard, click New Parameter.

  5. Select the Filter Field as State. Click Filter Parameters.

  6. In the Filter Parameters dialog box, click New Filter, and then specify the name of the new filter as StateFilter.

  7. Then select the type of the filter as Comparison. Select the Filter Field as State. Click OK to close the Filter Parameters dialog box.

  8. Enter the default value for the filter parameter as "Washington". Click OK, and then click Save to save the external content type.

Note that now end users will be able to enter their own custom filter values for the StateFilter to see filtered instances, for example, in an external list.

Tips and Warnings

  • When you take an external list that has been filtered offline in Microsoft Outlook or Microsoft SharePoint Workspace, only the instances that are currently available in the list are deployed on the client. For example, if you limit your list to show only customers from New Jersey and then click Connect to Outlook, only those customers who are from New Jersey will be deployed in Outlook.

Best Practices

  • You should define user filters for your SpecificFinder method and Finder method to limit the instances that come back from the backend. A Limit filter is recommended.

  • On input parameters, define system filters. On return parameters, define user filters.

  • Define default values for the filters; otherwise no instances will be brought back from the backend.

  • Define either a Limit filter or a Page filter on methods that return multiple instances.