Section 10.1.  Why use scripts?

Prev don't be afraid of buying books Next

10.1. Why use scripts?

Using a script, you can manipulate both the InfoPath user interface and the abstract XML document underlying the form. You can also call external code to add almost any functionality to a form. This can be useful in a broad range of situations, for example:

  • More complex validation. The standard validation functionality of InfoPath is quite powerful, but sometimes there are constraints that cannot be expressed using the standard features. For example, constraints that involve more than two fields in the form, or ones that require a calculation to be performed.

  • Calculations. Values, such as totals and averages, can be calculated based on other values specified by the user.

  • Custom error messages. Custom error messages can be created that are more meaningful than the basic ones provided by InfoPath.

  • Access to secondary data from a database, Web service or other XML document. A script is not required if you simply want to read and write an entire XML document from an external data source. However, a script is required if you want to use the secondary data source for validation, or to complete sections of the form. Because this is such a common use case, all of Chapter 11, "Using secondary data sources with forms", on page 250 is devoted to it.

  • Custom user interface components. Using a script, you can add custom toolbars, menus and task panes, optimizing the InfoPath environment for a specific set of users.

Scripts can be executed when the user clicks a button on the form, when the user changes a value, when a form is first loaded, or in response to a number of other events. In this chapter we will provide a number of examples of InfoPath scripts, focusing mostly on the XML aspects rather than user interface customization.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net