You are on page 1of 10

Introduction

InfoPath is designed to solve a core problem in data collection and integration needs in the enterprise via XML. Despite XML's potential to enable application integration, its use typically requires a development background that involves typically XML and XSL. Because of this, it is primarily employed in back-office and data center applications. But now with InfoPath, you can bring the XML functionality to the desktop by allowing users to gather and manage business data in XML without requiring those users to know the language themselves. By providing native XML support, InfoPath allows customers to more readily reuse the information created through their business processes. For example, InfoPath can be used by the line of business (LOB) applications to bring the power of back-end systems and applications such as Customer Relationship Management (CRM), Enterprise Resource Planning (ERP), and Supply Chain Management (SCM), to every desktop. On a team level, InfoPath may be used to address such tasks as weekly status reports, sales call tracking and so on. Because of its seamless integration with other Office family products such as Excel, Outlook, and Windows SharePoint Services, you can readily share business data with your team members.

Loading the XML Document into the DOM When you open an existing XML document in InfoPath, an internal representation of the XML document is created in memory as a DOM tree. A transformed view of the DOM tree is displayed to the end user. The DOM tree is then used by other InfoPath features, including editing, validating, saving, and submitting an XML document.

Figure shows how the DOM is used to load and store data for use by editing views.

Architecture of InfoPath
InfoPath's form design interface includes familiar controls, such as check boxes, date pickers, and text boxes. You can create forms by dragging these elements into a document editor that provides WYSIWYG view of the form, and traditional text editing and layout facilities are available to arrange and format the form elements. You can get most of these functionalities without having to write a single line of code even though a script editor is available if you wish to add more complex functionality. When you are designing a form using InfoPath, you have two options.

You can use one of the built-in sample templates provided by Microsoft for performing common tasks such as asset tracking, expense reports, project plans, and sales reports. These templates are fully functional, and can be used directly, or they can be customized to meet the needs of the user.
Or you can design a form from scratch and add all your custom functionalities. Data entered by users in InfoPath forms is stored in XML. InfoPath also provides out-of-the-box support for Web services protocols, including Simple Object Access Protocol (SOAP), Universal Description, Discovery, and Integration (UDDI), and Web Services Description Language (WSDL), making it an ideal client for Web services. You also have full control over the XML schemas used in this process, and you can bind form data controls to XML data elements by simply selecting them from a list.

Operations that can be performed using InfoPath

There are two main operations that you can do with InfoPath. Designing form templates You can design InfoPath forms using the WYSIWYG editor that can be based on XSD Schemas or WSDL. Filling out forms In this operation, when the user browses to a form template and InfoPath opens a form template allowing the user to fill out the form. For both of these tasks, you need InfoPath to be installed and available in the client machine.

Designing an InfoPath Form Template


When you design a new form template, you can either start from scratch by selecting New Blank Form or base it on an existing data source by selecting New from Data Source. The task pane (available in the right hand side of a blank form) provides links to the various tasks you might want to perform while designing a new form. Specifically, you'll want to control the form layout, place controls on the form for capturing different types of information, define how those controls map to your underlying data source, define different data views of the form, publish it and so on. After selecting New Blank Form, InfoPath provides a blank design surface in which you can drag and drop controls onto. As you're designing a form, you can select Preview Form to see what it will look like when the user fills it out. As you design a form from scratch, InfoPath automatically builds an XML Schema definition behind the scenes to represent the information that will be captured by your form. If you fill out an InfoPath form and save it to disk, InfoPath will produce an XML document that conforms to the schema. InfoPath also provides an advanced feature that enables optional and repeating sections. Optional sections can be hidden and displayed on demand, making it possible to simplify forms and decrease clutter. Repeating sections let you repeat blocks of information that occur multiple times in a schema. InfoPath also enables you to bind repeating controls to external data sources for automatic population of the control.

Designing a Simple InfoPath Form In this section, we will design a simple InfoPath form that can be used for entering the details of an employee. To create this form, let us follow the steps outlined below.
Open up InfoPath and select File->Design a Form from the menu, which results in the Design a New Form option being displayed in the Task Pane. Click on New Blank Form from the list of available options. From the Design Tasks pane, click on Controls to add controls to the form. In the Form editor, type in a text message that says Employee Details: and adjust the font size to 24 and center the text message. Then add a text message in the next line that says Employee ID: From the list of available controls, drag and drop a text box control right next to the caption and right click on it and select Textbox Properties from the context menu. In the Properties dialog box, change the Field Name to EmployeeID and then change the Data type to Whole Number (integer) from the drop down box. You can also set default value for the EmployeeID text box by entering an appropriate value in the Default value: textbox. After making all the changes, the properties dialog box should look somewhat similar to figure

The Properties dialog box also provides advanced built-in validation features that you can take advantage of. To set advanced validations, click on the Data Validation button and you will be presented with the dialog box in figure 2.

Figure 2. Using the Events drop down option, you can select a specific event and write code under that event. As you can see from the above figure, by default, it provides three events. From the Data Validation dialog box displayed above, you can also configure custom rules by clicking on the Add button. Clicking on the Add button results in the following screen (figure 3) in which you can set validation rules.

Figure3 In the same manner, add the remaining controls to the form. Also add a command button to the form and set the Label to Submit and change the Script ID as EmployeeSubmit using its properties dialog box. Then click on the Microsoft Script Editor to bring up the script editor. In the script editor, we will write few lines of code to simply display the data entered by the user in the textboxes. After making all the changes, the function should look similar to the following. function EmployeeSubmit::OnClick(eventObj) { XDocument.UI.Alert ("Employee ID : " + eventObj.Source.selectSingleNode("//my:EmployeeID").text); XDocument.UI.Alert ("Employee Name : " + eventObj.Source.selectSingleNode("//my:EmployeeName").text); XDocument.UI.Alert ("Employee City : " + eventObj.Source.selectSingleNode("//my:EmployeeCity").text); XDocument.UI.Alert ("Employee State : " + eventObj.Source.selectSingleNode("//my:EmployeeState").text); XDocument.UI.Alert ("Employee Zip : " + eventObj.Source.selectSingleNode("//my:EmployeeZip").text); }

After adding all of the controls, the form should look somewhat similar to figure 4.

Figure 4. To preview the form, click on the Preview Form option in the toolbox of the above screen. Using this option, you can test to see if the form behaves exactly the way you want. While previewing the form, you can also enter values on the textboxes, and click on the Submit button to see if it is displaying those alerts that we specified in the code earlier.

You might also like