Design a form template by using settings in a data connection library
This article shows you how to design a form template, which is based on the settings stored in a data connection library on a Microsoft Office SharePoint Server 2007 site, that can either query or submit data.
In this article
Overview
A secondary data connection is any data connection to an external data source that you add to a form template. This data connection is different from the main data connection that is created when you design a form template based on a database, Web service, or settings in a connection library. You add a secondary data connection only if you cannot query or send data through the main data connection.
A form can have one primary data connection, called the main data connection, and it can optionally have one or more secondary data connections. Depending on your goals for the form, a data connection might query or submit form data to an external data source, such as a Microsoft SQL Server database or a Web service.
If you are designing several form templates that use similar data connections, consider using a data connection file instead of creating a data connection to an external data source for each form template. This way, you need to update only one data connection file when the data connection information changes for a set of related form templates. For example, when you move your form templates from a test network to a production network, you need to update the data connection settings only once in the connection library instead of updating the data connection in each form template. When a form based on a form template that uses a data connection file uses the data connection, the data connection is automatically updated with the new settings.
A data connection file is an XML file with an .xml or .udcx file extension that contains connection information for a single external data source. This file is stored in a data connection library on a server running Microsoft Office SharePoint Server 2007. A data connection file is created by a developer or by converting a data connection in an existing form template into a data connection file by clicking the Convert button in the Data Connections dialog box (Tools menu).
Advantages of using data connection files include:
-
Multiple forms can use the same data connection file, so there is no need to create the same data connection from scratch for each form template.
-
If the location or connection settings for an external data source change, you need to update only the data connection file, not each form template.
-
The data connection file can contain alternative authentication information that can be used by the server when a user fills out a form by using a Web browser.
-
Forms based on a browser-compatible form template that are filled out in a browser can connect to servers in another domain only with data connections that use data connection files.
Microsoft Office InfoPath uses data connection files that follow the Universal Data Connection version 2.0 file format. This version is a superset of the version 1.0 file format used by Microsoft Office FrontPage and Microsoft Office Excel. InfoPath cannot use data connection files in the version 1.0 file format.
When you create a form template that is based on settings in a data connection file, Microsoft Office InfoPath creates a data connection that is based on the settings in the data connection library. If the data connection file contains settings for a query data connection, InfoPath creates the form's main data source with query fields, data fields, and groups that correspond to the way that data is stored in the external data source that is referenced by the settings in the data connection file. Query fields contain the data that the external data source uses to determine what to send to the form. The results of the query are put into data fields. To enable users to query the external data source, InfoPath adds a Run Query button to the form template.
Because the data structure of the query and data fields must match the way that data is stored in the external data source, you cannot modify existing fields or groups in the main data source. You can only add fields or groups to the root group in the main data source.
If you are using settings for a submit data connection, InfoPath enables the Submit button on the Standard toolbar and the Submit command on the File menu of forms that are based on this form template. This allows users to submit the data in their forms to the external data source.
Before you begin
In order to design a form template that is based on the settings in a data connection library, you need the following information from the data connection library administrator or the developer who created the data connection file:
-
The location of the Office SharePoint Server 2007 site with the connection library.
-
The name of the data connection file in the data connection library that you want to use.
Design a form template with a query data connection
In order to design a form template that is based on a data connection file with settings for a query data connection, you must do the following:
-
Design the form template that is based on the data connection file This step creates the main data source for the form template with the appropriate fields and groups that are based on the settings in the data connection file.
-
Add a control to the form template that will display the query results To display the data stored in the fields and groups in the main data source to your users, you have to add a control to your form template and then bind that control to a query field or data field in the main data source.
Step 1: Design the form template based on the data connection file
-
On the File menu, click Design a Form Template.
-
Under Design a new, in the Design a Form Template dialog box, click Form Template.
-
In the Based on list, click Connection Library.
-
If you are designing a browser-compatible form template, select the Enable browser-compatible features only check box.
-
Click OK.
-
In the Site list, in the Data Connection Wizard, click the name of the site on the server running Office SharePoint Server 2007 that includes the data connection library.
Add your site to the list
-
Click Manage Sites.
-
In the Manage Sites dialog box, click Add.
-
In the URL box, type the location of the data connection library.
-
In the Display name box, type a name for the data connection library. This name will appear in the Site list in the Data Connection Wizard.
-
Click OK.
-
Click Close.
-
-
Click the name of the data connection library to see a list of data connection files, click on the name of the data connection file that you want to use for this data connection, and then click Next.
-
If you selected a data connection file with connection settings to a Web service, the next page of the wizard may ask you to specify sample values for each parameter to determine what fields or groups to add to the secondary data source.
How?
-
Select a parameter in the Parameters table, and then click Set Sample Value.
-
In the Sample value box, type a value that your user might use for this field, and then click OK.
-
Repeat these steps for each parameter in the Parameters table, and then click Next.
Technical details
When you configure a data connection to a Web service in the Data Connection Wizard, Microsoft Office InfoPath connects to the Web service and requests the Web Service Description Language (WSDL) file. The WSDL file contains the schema used by the Web service. The Web service responds to the request by sending this file to InfoPath. InfoPath uses the information in this file to add the appropriate fields and groups to the secondary data source in the form template. If InfoPath finds an unknown element type in the WSDL file, InfoPath uses sample data to determine the definition of the unknown element type and then adds the appropriate fields and groups to the secondary data source.
-
-
If the external data source referenced in the settings returns a Microsoft ADO.NET DataSet, the next page of the wizard asks if you want to include change information when users submit their form data. In most cases, leave the Include change information when submitting data check box selected, and then click Next. If you do not want to include change information, clear the Include change information when submitting data check box, and then click Next.
Technical details
This page in the wizard appears only if the settings are for a Web service and the Web Service Description Language (WSDL) file indicates that the Web service returns an ADO.NET DataSet.
-
On the next page of the wizard, type a name for the data connection, and then click Finish.
Step 2: Add a control to display the data in the field
-
If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.
-
Drag a control onto your form template.
-
In the Control Binding dialog box, select the field that you want to bind the control to.
Design a form template with a submit data connection
If the data connection file contains settings for a submit data connection, you can configure your form template to allow users to submit their form data through the data connection. When you do this, InfoPath adds a Submit button to the Standard toolbar and a Submit command to the File menu. You can configure the submit options for the form in the Submit Options dialog box (Tools menu). The submit options are configured in the same way as if you designed a form template based on a database or Web service. Find links to more information about designing a form template that is based on a database or Web service in the See Also section.
-
On the File menu, click Design a Form Template.
-
Under Design a new in the Design a Form Template dialog box, click Form Template.
-
In the Based on list, click Connection Library.
-
If you are designing a browser-compatible form template, select Enable browser-compatible features only.
-
Click OK.
-
In the Site list, in the Data Connection Wizard, click the name of the site on the server running Office SharePoint Server 2007 that includes the connection library.
Add your site to the list
-
Click Manage Sites.
-
In the Manage Sites dialog box, click Add.
-
In the URL box, type the location of the data connection library.
-
In the Display name box, type a name for the data connection library. This name will appear in the Site list in the Data Connection Wizard.
-
Click OK.
-
Click Close.
-
-
Click the name of the data connection library to see a list of data connection files, click the name of the data connection file that you want to use for this data connection, and then click Next.
-
If you selected a data connection file with connection settings to a Web service, the next page of the wizard may ask you to specify sample values for each parameter to determine the best field or group to add to the secondary data source.
How?
-
Select a parameter in the Parameters table, and then click Set Sample Value.
-
In the Sample value box, type a value that your user might use for this field, and then click OK.
-
Repeat these steps for each parameter in the Parameters table, and then click Next.
Technical details
When you configure a data connection to a Web service in the Data Connection Wizard, Microsoft Office InfoPath connects to the Web service and requests the Web Service Description Language (WSDL) file. The WSDL file contains the schema used by the Web service. The Web service responds to the request by sending this file to InfoPath. InfoPath uses the information in this file to add the appropriate fields and groups to the secondary data source in the form template. If InfoPath finds an unknown element type in the WSDL file, InfoPath uses sample data to determine the definition of the unknown element type and then adds the appropriate fields and groups to the secondary data source.
-
-
On the next page of the wizard, type a descriptive name for the data connection, and then click Finish.
No comments:
Post a Comment