Thursday, April 13, 2017

Introduction to submitting form data

Introduction to submitting form data

In this article

Overview

Submitting form data to an Access or SQL Server database

Submitting form data to a Web service

Submitting form data to a server running Microsoft Windows SharePoint Services

Submitting form data in an e-mail message

Submitting form data to an application on a Web server

Submitting form data by using a data connection file

Submitting form data by using code

Overview

When you use Microsoft Office InfoPath forms to collect data as part of a larger business process, that data usually doesn't stay in the forms that users fill out. Instead, the form data moves from the form to the next stage in the business process, usually to an external data source such as a database, Web service, or application on a Web server. For example, an employee might use InfoPath to fill out an expense report form and then submit that form to a Web service where the form can be processed.

An InfoPath form being submitted to an external data source

Unlike saving a form, where users choose a location to store their form while they fill it out, submitting a form sends the form's data to a specific location that was defined when the form template that is associated with the form was designed. When you design a form template and enable form submission, you can choose to have the data that users enter into your form submitted to the following locations:

  • A Microsoft Office Access or Microsoft SQL Server database

  • A Web service

  • A server running Microsoft Windows SharePoint Services

  • In an e-mail message

  • An application on a Web server

  • A custom application that hosts InfoPath

Specifying where you want the data in your forms to be submitted can increase the accuracy and efficiency of your business processes, because it allows you to exert more control over those processes. Before users can submit their form data, InfoPath ensures that the data in the forms is valid and allows the users to correct any invalid data. This feature can help ensure that only valid data is sent to the external data source.

In addition to designing your form template to allow users to submit their data to a single location, you can design your form template so that users can submit their form data to multiple locations at once. For example, you can design an expense report form template so that when users submit their completed forms, the forms' data is sent to a database, and a copy of each completed form is also sent in an e-mail message to their manager.

Whenever you design a form template that can be submitted to an external data source, InfoPath turns on the Submit command on the File menu, as well as the Submit button on the Standard toolbar by default. Depending on your needs, you can choose to change the name of the Submit command. In addition, you can also insert a button directly on the form template that users can click to submit their form data after they finish filling out the form.

You can also set up your form template so that one of the following occurs after the form is submitted:

  • The existing form closes.

  • The existing form closes and a new, blank form opens.

  • The existing form remains open.

In addition, you can write a message that appears after users submit their form that specifies whether the form was submitted successfully.

Top of Page

Submitting form data to an Access or SQL Server database

InfoPath forms are frequently submitted to databases, whether it is to update a single table with a customer record or for more complicated scenarios, such as modifying multiple tables that are linked together in an expense report form template. You can design your form template in InfoPath so that it can be submitted directly to an Access or SQL Server database without requiring that you use script or custom code. You can also submit form data to other types of databases by using custom code or by submitting the form to a Web service that is connected to that database.

In order to submit a form to an Access or SQL Server database, you must design a form template that is based on that database. This ensures that the form template's data source matches the structure of the database. If you add a database connection to an existing form template, users won't be able to submit their completed forms to the database, because the form's data source does not match the structure of the database. If the form template does not match the structure of the database, InfoPath cannot update the correct fields in the database when the data is submitted.

When you design an InfoPath form template that is based on a database, note the following issues:

  • When you connect the form template to more than one table in the database, the tables must be connected by key fields.

  • Long data types, such as pictures, images, OLE objects, file attachments, and Access Memo or SQL data types, should be excluded from the data connection. InfoPath does not support data connections to these long data types. To exclude specific fields in the database, use the Data Connection Wizard to set up the data connection.

You can determine whether either of these issues applies by reading the information in the Summary box on the last page of the Data Connection Wizard. The Summary states whether form submission is enabled, and if it is disabled, the Summary explains why.

After you set up the data connection between the form template and the database, you can customize any other submit options that you want. For example, you can change the text that appears on the Submit button in your form template. You can also change the messages that are displayed to users to indicate if the form was successfully submitted, and you can specify whether to keep the form open after submission.

Top of Page

Submitting form data to a Web service

Whether you use a Web service to establish a workflow for a business process or as a middle tier on top of your database, InfoPath makes it easy to create form templates that interact with a Web service. InfoPath has a Data Connection Wizard that guides you through the process of connecting form templates to a Web service.

There are two common methods of designing a form template that submits forms to a Web service:

  • Connecting an existing form template to a Web service

  • Designing a new form template that is based on a Web service

With both of these methods, InfoPath creates a data source that is based on the schema of the Web service. This enables forms that are based on a form template to submit data to the Web service.

Technical details

When users submit a form to a Web service, the form is sent as Extensible Markup Language (XML) data in a SOAP envelope. The SOAP envelope functions as an input parameter for the specified Web service operation. You can compare this to submitting a form by using HTTP, which results in an XML document in an HTTP POST request.

Before you connect an InfoPath form template to a Web service, consider the following:

  • InfoPath cannot connect to a Web service that uses remote procedure call (RPC) encoded style. Only document literal encoding is supported.

  • When you configure a form template so that its forms can submit data to a Web service, you can specify that only data in certain fields or groups can be submitted, or you can submit all of the data in the form.

After the data connection to the Web service is set up, you can add a Submit button to the form template and customize any other submit options that you want.

Top of Page

Submitting form data to a server running Microsoft Windows SharePoint Services

You can design a form template that submits data to a server that is running Microsoft Windows SharePoint Services. By doing this, you can store and organize all of your users' forms in a document library. In addition, your users can fill out forms that are based on the form template directly from the document library. They can also export form data to Microsoft Office Excel or merge the data from several forms into a single form. In addition, when you enable form submission directly to a document library, you can predefine the file names for the forms, either with static values, with values based on data in the form, or by using a formula.

After configuring the form template to allow form submission to a SharePoint document library, you can add a Submit button to the form and customize other submit options, such as the text on the Submit button, the messages displayed to the user to indicate if the form was successfully submitted, and whether to keep the form open after submission.

Top of Page

Submitting form data in an e-mail message

Using an e-mail program is one of the easiest and most common ways of setting up a workflow for a business process. You can design an InfoPath form template that lets users click a Submit button on the Standard toolbar or on the File menu to send their completed form either as an attachment or in the body of an e-mail message. The e-mail addresses, subject line, and attachment file name can all be predefined when you design your form template — either with static values, with values based on entries in the form, or by using a formula. For example, you can design your form template so that completed forms are automatically sent in an e-mail message with a predefined subject line to an e-mail address that is based on an entry in the form. In addition, based on data that users enter in the form, you can define dynamic file names for the form.

In order for users to submit their forms as e-mail messages, they must have Microsoft Office Outlook 2003 or Microsoft Office Outlook 2007 installed on their computers. Users who fill out forms in a Web browser do not need Outlook to submit their forms as an e-mail message.

After configuring the form template to allow form submission in an e-mail message, you can add a Submit button to the Standard toolbar and a Submit command to the File menu to the form template and customize any other submit options, such as the text that appears on the Submit button, the messages displayed to the user to indicate if the form was successfully submitted, and whether you want to keep the form open after submission.

Top of Page

Submitting form data to an application on a Web server

If you have an existing Active Server Pages (ASP) page or other code on a Web server that can process XML data, you can design your form template so that users can submit completed forms to that Web server by using the HTTP POST method. When you configure your form template to allow users to submit their forms in this way, InfoPath creates a message that includes the form data and then sends this message to the Web server. When designing a form template to submit data to a Web server, you can add a Submit button to your form template, specify the text that appears on the Submit button, customize the messages that are displayed to users to indicate if the form was successfully submitted, and specify whether to keep the form open after submission.

Top of Page

Submitting form data by using a data connection file

In Microsoft Office InfoPath 2007 you also have the ability to create an XML file called a data connection file that includes all of the settings necessary for a data connection. You can store that file in a data connection library in a Microsoft Office SharePoint Server 2007 site, and then design several form templates that use the same XML file to configure a data connection. Using a data connection file means that if anything with the data connection changes — for example, if the location of the external data source changes — you can update the data connection file once, rather than updating the data connection in each individual form template. All form templates that use the data connection file will be automatically updated with the new settings.

A data connection file can contain settings that determine how users can submit their form data. You can design a form template to use the settings in this data connection file. After configuring the form template to allow form submission, you can add a Submit command to the File menu and a Submit button to the Standard toolbar on the form that is based on the form template, and then customize any other submit options, such as the text that appears on the Submit button and command, the messages displayed to the user to indicate if the form was successfully submitted, and whether you want to keep the form open after submission.

Top of Page

Submitting form data by using code

To create advanced functionality in your form template for submitting form data, you can write managed code by using Microsoft Visual Basic .NET, Microsoft Visual C# .NET, or a script. For example, you can add functionality to your form template that enables form submission to more than one location at once or to an external data source that is not normally supported by InfoPath.

Tip: If you cannot configure your form template to allow users to submit their forms to an external data source by using the InfoPath data connection options, you can use this feature to write your own implementation of a data connection to that external data source.

Top of Page

No comments:

Post a Comment