共用方式為


How to: Embed an External Item Picker Control in an InfoPath Form

Applies to: SharePoint Server 2010

Microsoft InfoPath 2010 provides an External Item Picker control that you can use to embed a picker in a form for scenarios where a user needs to pick an external item from a SharePoint list, such as customer John from a list of Customers. An External Item Picker provides picking and resolving functionality for external items on the server and in rich-client Microsoft Office applications.

If you have set up associations for external content types in the BDC Metadata Store and if the external content type contains a foreign key, Microsoft Business Connectivity Services (BCS) automatically adds a picker control to the form for that field. For example, consider a customer/order scenario. Let's assume the external content types and the association are set up. If you customize the Order external list form in InfoPath, Business Connectivity Services by default puts an External Item Picker control for the CustomerID field in the Order form. This enables users to easily find the customer they want when working with orders.

However, if your autogenerated InfoPath form is blank because the SpecificFinder has one or more complex types, you must drag an External Item Picker control from the Server ribbon and set the required properties. You might also want to enable this picking and resolving functionality from a custom InfoPath form.

To embed an External Item Picker control, drag the External Item Picker control onto the design surface in InfoPath 2010, and then set the properties on the General tab and on the Other Settings tab. Table 1 lists the settings that you might need to fill in when using a picker in a form.

Table 1. Settings to provide when using picker in a form

Tab

Field

Description

General

ECT Namespace

The entity namespace from the BDC Model.

ECT Name

The name of the external content type, as in the BDC Model.

System Instance Name

The LOBSystemInstance name from the BDC Model.

Finder Name

The name of the Finder method to use to populate the picker dialog box. This field is optional and if it is not specified, Business Connectivity Services uses the default finder from the BDC model.

Display Field Name

The field you want to display in the picker. This should be the name of a TypeDescriptor returned by the Finder.

SharePoint Site URL

Optional site URL field. Not needed if this form is published to a SharePoint site.

Dialog Title

The title for the dialog box that displays external items and enables users to pick one or more items.

Show More Results

If this check box is selected, Business Connectivity Services displays a Show More Results button in the dialog box.

Maximum Number of Results

The maximum number of results to show in the dialog box. The default is 100.

Refresh Interval (in minutes)

The frequency in which to refresh the cache. The default is to refresh every 360 minutes.

Maximum Number of Lines

Visible lines in the picker control for multiple selection.

Other Settings

Default Query

The filter value Business Connectivity Services to use each time the picker dialog box is opened. If this is not specified, all items are retrieved each time the dialog box is opened.

Query By Default

The query to execute by default each time the picker dialog box is opened.

Allow Multiple Selection

If selected, enables users to select more than one item. You may have to write code-behind to support this functionality in your form.

Refresh on Open

If selected, the data is refreshed from the external system on form load.

Picker Mode

Default is the local Business Connectivity Services Cache first, if that is empty, then connect to the external system. Other available options are:

Local Cache Only

Connect to External Data Source Directly

Connect to External Data Source Through SharePoint

Figure 1 shows how the General tab might look for getting the Customer external content type from AdventureWorks.

Figure 1. External Item Picker General tab in InfoPath

External item picker General tab

Figure 2 shows the Other Settings tab. You can ignore the fields that are not highlighted in this figure.

Figure 2. External Item Picker Other Settings Tab in InfoPath

External item picker Other Settings tab