Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office InfoPath
Search
Search
 
Check for updates: (c) Microsoft
Office downloads
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
One Submit button: Many data sources
 
Applies to
Microsoft Office InfoPath® 2003 Service Pack 1 or later

Faces of Office This article was written by Ned Friend, a Program Manager for Microsoft Office InfoPath.


I've been designing features for Microsoft Office InfoPath 2003 since its inception, and continue to design improvements based on customer feedback. With the first release of the program, it was easy to submit the data in an InfoPath form to a Web service or database. However, we started hearing a lot of requests from customers who wanted us to make it equally easy to submit forms through e-mail messages and submit form data to form libraries on Microsoft Windows SharePoint Services Web sites. Customers also wanted to submit their form data to multiple data sources without having to write script.

In an effort to address these requests, we designed a feature for our first service pack that allowed form designers to use rules to customize how their forms were submitted. We also added new data connections for form libraries and e-mail messages. With the use of rules, form designers can add a Submit button to their form that submits form data to multiple data sources at the same time. In addition, form designers can further customize this Submit button so that form data is submitted to different data sources depending on the data that is entered into the form.

Submitting form data to multiple data sources at once

With InfoPath rules and data connections, it's easy to submit form data to multiple locations at the same time. After you enable this feature in your form template, your users can simply fill out the form, and then click the Submit button once to send their form data to a database, form library, and Web service, in addition to sending the form in an e-mail message.

If this sounds like a scenario you're interested in, the following steps will walk you through the process of enabling your form template to submit form data to multiple locations at once.

  1. Open your form in design mode.
  2. On the Tools menu, click Submitting Forms.
  3. In the Submitting Forms dialog box, click Enable Submit commands and buttons.
  4. In the Submit to box, click Custom submit using rules, and then click Rules.
  5. In the Rules for Submitting Forms dialog box, click Add.
  6. In the Rule dialog box, click Add Action.
  7. For the Action box, click Submit using a data connection, and then do one of the following:
    • To use an existing a data connection, select it in the Data Connection list.
    • To create a new data connection, click Add, and then follow the steps in the Data Connection Wizard.

      Note  For help on creating a data connection, refer to the links in the See Also section.

  8. Repeat step 6-7 for each data source that you want to submit data to.

Submitting form data based on a condition

We also heard from customers who wanted the ability to submit form data to different data sources depending on the data in the form. For example, if the expenses entered into an expense report form exceed $1,000, when the user clicks the Submit button the form is automatically sent in an e-mail message to the user's boss for approval. If the expenses entered into the form are less than $1,000, the form data is submitted directly to a Web service.

To address this scenario, we added conditions to the rules feature in InfoPath, which allow you to add multiple rules to your form template, each with its own condition:

  1. Open your form in design mode.
  2. On the Tools menu, click Submitting Forms.
  3. In the Submitting Forms dialog box, click Enable Submit commands and buttons.
  4. In the Submit to box, click Custom submit using rules, and then click Rules.
  5. In the Rules for Submitting Forms dialog box, click Add.
  6. In the Rule dialog box, click Set Condition.
  7. In the Condition dialog box, specify when the data connection should be used. For more information on creating a condition, refer to the links in the See Also section.
  8. In the Rule dialog box, click Add Action.
  9. For the Action box, click Submit using a data connection, and then do one of the following:
    • To use an existing a data connection, select it in the Data Connection list.
    • To create a new data connection, click Add, and then follow the steps in the Data Connection Wizard.

      Note  For help on creating a data connection, refer to the links in the See Also section.

  10. Repeat steps 5-9 for each data connection that has its own condition.

Reusing data connections in script

Finally, for those of you who know how to write script, we heard requests from customers who wanted to make the Data Connection Wizard create objects for scripting. Customers wanted to reuse the built-in data connections in their script, so we added the DataAdapters collection to the XDocument object in the InfoPath Object Model. Now every data connection that you add to your form template is also available by the same name in your script. For example, if you use the Data Connection Wizard to create two data connections, one named "My web service" and another named "Email my boss", you can write the following script to use them:

Microsoft Visual Basic Scripting Edition (VBScript)
XDocument.DataAdapters("My web service").Submit
XDocument.DataAdapters("Email my boss").Submit
JScript
XDocument.DataAdapters["My web service"].Submit();
XDocument.DataAdapters["Email my boss"].Submit();

Conclusion

I hope these tips help you get the most out of these features, and that they provided you with some insight into why we added them to the product in the first place. Keep the feedback and requests coming. We're listening.


Ned Friend, Program Manager for Microsoft Office InfoPath About the author  Ned Friend has been a Program Manager for Microsoft Office InfoPath since 2001. He has worked on the full range of InfoPath features, and his designs have earned him four patents for his innovations in XML schema creation, workflow, and rules.

advertisement