About programming InfoPath
Microsoft Office InfoPath 2003 provides developers with a rich development environment for customizing forms. Forms can be customized by writing programming code to respond to form and data validation events, to access and manipulate a form's underlying XML document, to implement custom data submission and merges, and to implement access to external data sources. Customizing a form can also involve altering one of the form files to suit a specific requirement.
It is important to understand a few key concepts that are involved in programming an InfoPath form. These concepts include the InfoPath programming components, programmatic and declarative programming, the InfoPath programming languages, and the InfoPath programming environment.
InfoPath programming components
InfoPath programmability involves customizing an InfoPath form by altering its form files or by writing scripting code to create custom functions using the InfoPath object model. The main components of an InfoPath form that can involve programmatic interaction are listed in the following table.
Component | Description |
---|---|
Object model | A robust, hierarchical type library composed of collections, objects, properties, methods, and events that give form developers programmatic control over various aspects of the InfoPath editing environment and access to a form's underlying XML document. |
Data validation | A combination of XML Schemas, expressions, and scripting code used to validate and constrain the data that users are allowed to enter in a form. |
Event handling | A set of event handlers that respond to changes to a form's underlying XML document, respond to view switching, implement custom form submission, or respond to the loading of the form's underlying XML document. |
User interface | A set of customizable user interface components that includes menus, toolbars, buttons, command bars, and a task pane. |
Editing controls | A set of InfoPath-specific controls used to manage and interact with the form's underlying XML document that includes collections, optional items, text lists, and fields. |
Error handling | A combination of event handlers, object model calls, and form definition (.xsf) file entries that are used to handle errors in an InfoPath form. |
Security | A set of security levels that restrict access to the InfoPath object model and system resources. |
Data submission | A set of predefined functions that can be used to implement custom posting and submission functionality for an InfoPath form. |
Business logic | A set of custom scripting files that contain programming code used to implement specific editing behavior, data validation, event handlers, and control of data flow. Business logic can also include accessing of external Component Object Model (COM) components. |
Form integration | Integration of other Microsoft Office applications such as Microsoft Excel or Microsoft Outlook. Integration may also involve the use of back-end servers such as Microsoft SQL Server, Microsoft Windows SharePoint Services, or XML Web services. |
Programmatic and declarative development
When you alter the InfoPath form files, you customize the form declaratively
The following are some of the ways in which a form may be customized declaratively:
- Modifying the XML Schema (.xsd) files
- Modifying the view (.xsl) files created in design mode
- Modifying the form definition (.xsf) file
- Modifying the XML template (.xml) file
The following are some of the ways in which a form may be customized programmatically:
- Adding form lifecycle processing logic
- Adding custom data validation
- Adding custom error handling
- Implementing data submission
- Responding to a form merge (or import)
- Using custom task panes
- Using custom dialog boxes
- Accessing and modifying a form's underlying XML document
- Accessing and modifying the form definition file
- Using external COM components
InfoPath programming languages and the programming environment
Like other Microsoft Office applications, InfoPath provides a programming environment and programming languages that developers can use to automate and extend their Office applications. However, while most Office applications use Microsoft Visual Basic for Applications (VBA) as their primary programming language, InfoPath uses two scripting languages