Using Business Data Catalog Actions to Pass Parameters to InfoPath 2007 Browser Forms

Summary:  Learn how to use Business Data Catalog actions to pass parameters to Microsoft Office InfoPath 2007 browser forms.

Office Visual How To

Applies to:  2007 Microsoft Office System, Microsoft Office InfoPath 2007, Microsoft Office SharePoint Server 2007

David Gerhardt, 3Sharp

April 2007

Overview

You can build forms with Microsoft Office InfoPath 2007 that run both in InfoPath 2007 and in a Web browser. For browser scenarios, you can integrate with the Business Data Catalog in Microsoft Office SharePoint Server 2007 by having a custom action pass a parameter value to form files.

Code It

Whether you pass a parameter to a form file in InfoPath 2007 or the Web browser, first you need to update the form template's Loading event. The LoadingEventArgs class of the Loading event provides the InputParameters property. This property gets an IDictionary object, which contains any input parameters that are specified in the URL that is used to start a form file. For this scenario, use the status report sample that comes with InfoPath 2007 to retrieve a parameter value passed in a browser URL.

Program the Loading Event

To add the Loading event stub to your form code file, on the Tools menu, point to Programming, and then click Loading Event. Next, use the TryGetValue method of the IDictionary object that was returned by the InputParameters property to retrieve a parameter value. Then, use the SetValue method on an XPathNavigator object to set the corresponding node value in the form file. The following example sets the Project box to the value of the CustomerID parameter that was passed in the URL that was used to start the form. The Project box is bound to the projectName node in the data source.

Note

You can set the programming language to Visual Basic or C# before you add event stubs to the form code file. To make such a change, on the Tools menu, point to Form Options, click the Programming category, and then set the Form template code language list value accordingly.

Deploy the Form Template

The form template uses managed code for a browser scenario. Therefore, an administrator must deploy it. First, you need to publish the form template to a network share.

To publish the form template to a network share

  1. In InfoPath 2007, on the File menu, click Publish.

  2. In the first page of the Publishing Wizard, click To a SharePoint server with or without InfoPath Forms Services, and then click Next.

  3. In the next page of the Publishing Wizard, type the URL for the SharePoint site in the Enter the location of your SharePoint or InfoPath Forms Services site box, and then click Next.

  4. In the next page of the Publishing Wizard, note that the Administrator-approved form template option is selected, and then click Next.

  5. In the next page of the Publishing Wizard, click Browse, navigate to a network share location, type StatusReport in the File name box, and then click Save.

  6. In the Publishing Wizard, click Next.

  7. In the next page of the Publishing Wizard, note the promoted columns, and click Next.

  8. In the next page of the Publishing Wizard, click Publish.

  9. In the last page of the Publishing Wizard, click Close.

After the form template is published to a network share, a server administrator then uploads that form template to InfoPath Forms Services and activates it to a specific Windows SharePoint Services 3.0 site collection.

To upload a form template to InfoPath Forms Services and activate the template to a specific site collection

  1. Click the Start button, and then point to All Programs. Point to Microsoft Office Server, and then click SharePoint 3.0 Central Administration.

  2. On the Central Administration Web page, click Application Management.

  3. In the InfoPath Forms Services section, click Manage form templates.

  4. On the Manage Form Templates page, click Upload form template.

  5. Click Browse, navigate to the location of StatusReport.xsn, and double-click it.

  6. Click Upload.

  7. Click OK.

  8. From the StatusReport.xsn menu, click Activate to a Site Collection.

  9. Update the Site Collection list value accordingly and click OK.

Create the Custom Business Data Catalog Action

You must update the Business Data Catalog metadata file to include a custom action. For this scenario, you can use the metadata file from the Visual How To article titled Creating Business Data Catalog Entities in SharePoint Server 2007. The following example adds a custom action to the existing Customer entity (before the </Entity> end tag) that starts the status report form in the Web browser with a CustomerID parameter.

Note

You need to replace the URL_to_WebApplication in the Url attribute with the actual URL for the Web application.

Note

Make sure you increment the Version attribute value in the LobSystem element and save the metadata file before uploading it into the Business Data Catalog shared service.

Upload the Metadata File into the Business Data Catalog Shared Service

After the metadata file is updated, navigate to the Business Data Catalog Applications page in Central Administration and import the new application definition.

To import the new application definition

  1. Click Start, and then point to All Programs. Point to Microsoft Office Server, and then click SharePoint 3.0 Central Administration

  2. Click your shared service provider (usually named SharedServices1).

  3. In the Business Data Catalog section, click Import application definition.

  4. Click Browse, navigate to the saved Business Data Catalog metadata file, and double-click it.

  5. Leaving all other application definition settings with their default values, click Import.

Add a Business Data List Web Part and Invoke the Status Report Action

To test your changes, add a Business Data List Web part to any site in your SharePoint Server 2007 installation and then invoke the Status Report action for one of the customers.

To add a Business Data List Web part and then invoke the Status Report

  1. In Internet Explorer, navigate to any SharePoint site, click Site Actions, and then click Edit Page.

  2. Within any of the zones on the page, click Add a Web Part.

  3. In the Add Web Parts dialog box, select the Business Data List check box, and then click Add.

  4. In the Business Data List Web part, click Open the tool pane.

  5. In the Business Data List task pane, type Customer in the Type box and press ENTER.

  6. Click OK to see the customer entries exposed in the Web part.

  7. Click the Name list for one of the customer entries and click Status Report.

Figure 1. Invoking the Status Report action

Invoking the Status Report actionRead It

With InfoPath 2007, you can build forms that accept parameters from either the command line or a browser URL. In the latter case, you can integrate with the Business Data Catalog by using a custom action to pass a parameter value to a browser form file. To support a browser form solution that integrates with a custom Business Data Catalog action, you need to do the following:

  • Add custom code to the form template's Loading event that retrieves a parameter value with the TryGetValue method of the IDictionary returned by the InputParameters property. After the parameter value is identified, you can use the SetValue method on an XPathNavigator object to update a node value in the form's data source.

  • Upload the form template to InfoPath Forms Services and activate it to a SharePoint site collection. Use the InfoPath Publishing Wizard to save the form template to a network share. Then a server administrator uses Central Administration to perform the upload and activation procedures.

  • Add an Action element to the Business Data Catalog metadata file that points to the URL of the browser form and passes a parameter. You must increment the Version number of the LobSystem element before you import the new application definition in Central Administration.

See It Video for Using Business Data Catalog Actions

Watch the Video

Length: 09:08 | Size: 9.56 MB | Type: WMV file

Explore It