Section 7.1.Are InfoPath Forms Better?


7.1. Are InfoPath Forms Better?

Creating data entry forms is perhaps the number one programming task today. Years ago, Visual Studio made this task easier with controls and drag-and-drop design tools; however Windows and Web form design is still much too hard for non-programmers.


Note: Do we need another forms engine? Face it, InfoPath is just another way to display data entry forms, similar to web forms in ASP.NET and Windows forms in err... Windows. The main difference is that InfoPath forms are XMLbased, which means you can easily create those forms from XML data sources.

InfoPath provides form design tools that can be used by intermediate to advanced Office System users. It simplifies design, distribution, validation, and data collection tasks; plus, InfoPath provides templates for the most common types of forms. This simplification is possible because InfoPath is based on a several assumptions:

  • Most forms reflect some underlying data source.

  • There is a well-defined set of actions you want to perform on that data source: Query, Refresh, Validate, Submit, Change View.

  • Users expect Office-like editing tools such as autocorrect and spell checking.

Because these assumptions are built in to the design of the product, InfoPath makes performing those tasks much easier. Specifically, tasks that were formerly done by programming can now be done by setting control properties or adding predefined actions and rules to controls. This approach is called declarative programming and it contrasts with the imperative approach most programmers are used to.

Finally, InfoPath forms are based on XML. You can create them from existing XML or XSD files or any XML data source, such as a web service or Access/SQL database. Why is this important? Because it provides a standards-based way to integrate data collected by InfoPath into other systems in an enterprise.


Note: For certain types of applications, InfoPath forms can save you a great deal of work. They aren't a silver bullet, though, and you need to judge when their use is appropriate.

7.1.1. Where to get it

InfoPath is included with the Microsoft Office System Professional Enterprise Edition. That edition is available through volume licensing only. However, you can try InfoPath for 60-days through the InfoPath 2003 Evaluation Kit or buy it as a standalone product outside of the Office System.

7.1.2. What about...

ToLook here
Evaluate InfoPath (60-day trial) www.microsoft.com/office/infopath/prodinfo/trial.mspx
Buy InfoPath www.microsoft.com/office/infopath/howtobuy/default.mspx


The Version 1.0 release of InfoPath is an interesting first attempt, but the SP1 release provides many more capabilities including additional controls, actions, programmability, links to SharePoint lists, and much more. If at all possible, you should work with the SP1 releasethis chapter uses that release throughout, though I do note where key features aren't available in Version 1.0.


Note: The SP1 preview expired July 31, 2004, and is now part of Office 2003 Service Pack 1.

7.1.3. How to do it

InfoPath is both a form designer and a form viewer, so InfoPath tasks can be divided between Designers and Users as shown in Figure 7-2.

Figure 7-2. InfoPath both designs and views forms


To design a form:


Note: Why doesn't InfoPath have a separate, distributable runtime? I don't know. For now, Microsoft licenses the design and runtime environments together and there's no way to separate the two, though you can disable the design mode (see "Prevent Design Changes").

  1. Start InfoPath and choose File Design a Form. InfoPath displays the Design a Form Task Pane.

  2. If you select a sample and click OK, InfoPath opens the sample in design mode (Figure 7-4).

You can modify the form by selecting any of the options in the Task pane.

To preview the results of changes:

  • Choose File Preview Default. InfoPath displays the form in Preview mode (Figure 7-5).

Once you are satisfied with a form, you have a choice: you can save the form for local use or testing, or you can publish the form for others to use. To publish a completed form:

Figure 7-3. Modify an existing sample to get a quick start


Figure 7-4. The Asset Tracking form in design mode


  1. Choose File Publish. InfoPath starts the Publish wizard to walk you through the process.

  2. Note: In preview mode, you can view changes, test controls, but not save data entered on the form.


    Figure 7-5. Viewing changes in Preview mode


    Figure 7-6. Use the Publishing Wizard to deploy a form


  3. If you chose to publish to a Web server, the Wizard prompts for the location of the server (Figure 7-7).

  4. Finally, the Wizard displays the address of the published form (Figure 7-8).

Once you've published a form, you can open it from the published address. For example, if a form is published to wombat1/assets.xsn as shown previously, you can open it for data entry by navigating to that address in Internet Explorer or by using the File Open command in InfoPath.

Figure 7-7. You can publish forms to web addresses


Figure 7-8. The Wizard displays the location of the published form, you can specify an alternate address to publish to another location as well


In either case, InfoPath opens the form template to create a new XML data file. If you enter data and save the form, InfoPath prompts you for a location to save the data with the default set as your local machine (Figure 7-9).

Figure 7-9. Warning: if you open the form template (.xsn), data is saved as a new form (.xml)


Since InfoPath forms are generally intended to collect and share data, saving data locally is not what you usually want to have happen! To solve this problem, follow these steps:

  1. Open the form in user mode and save it without entering any data. This creates a "starter" XML file that can receive subsequent data.

  2. Copy the XML file created in Step 1 to a public location. This will usually be the same server where the form is published, though it doesn't have to be the same.

  3. Tell users to open the XML file from its public location to enter or view data.


Note: Only one user can have the XML data file open for editing at a time. During that time, other users are allowed readonly access only. For shared access, see the section "Share Data."

7.1.4. How it works

When in design mode, InfoPath creates form template that contains the information InfoPath uses to display the form, collect data, and save that data. When in user mode, InfoPath interprets that form template to create form data files or to exchange XML data with a database, Web service, or other data source.

If you open the form data file in Notepad, you'll see processing instructions that associate that file with InfoPath and with the published location of the form template, as shown in the following XML fragment:

Figure 7-10. Open the XML file to enter or view shared data


   <?xml version="1.0" encoding="UTF-8"?>   <?mso-infoPathSolution solutionVersion="1.0.0.4" productVersion="11.0.5531"   PIVersion="1.0.0.0" href="http://wombat1/assets.xsn" ?>   <?mso-application prog?>   <at:assetTracking xmlns:my="http://schemas.microsoft.com/office/infopath/   2003/myXSD" xmlns:at="http://schemas.microsoft.com/office/infopath/2003/   sample/AssetTracking" xml:lang="en-us">     <at:dateModified xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/   XMLSchema-instance"></at:dateModified>  <at:owner>             <at:name></at:name>

You must change the href attribute shown above in bold if you move the published template to a new location or change its name.


Note: SharePoint Form Libraries provide a Relink button that can be used to fix this processing instruction if the Form Library is moved.

If you open the template file (.xsn) in Notepad, you might be surprised to find that you can't read itit's just a bunch of gobbledygook! Templates are actually compiled from a collection of different files.

To see the contents of a form template:

  1. Open the form template in Design mode.

  2. Choose File Extract Form Files. InfoPath displays a Browse for New Folder dialog to let you create a destination folder for the component files.


  3. Table 7-1. InfoPath file types
    FileTypeDescription
    Form template .xsnDefines the form to display to users.
    Form data .xmlStores data entered through the form.
    Manifest file.xsfDescribes the contents of the form template. This file brings together all of the internal data (.xml), schemas (.xsd), scripts (.js/.vbs), resource files, and transformations (.xsl) used by the form template. This file also describes the actions and custom data validation rules for the form.
    Components used by manifest file ( manifest.xsf ) .xmlProvides static data displayed in controls on the form. Template.xml stores the initial data for new form data files. Sample.xml provides sample data used when designing the form.
      .xsdXML schema descriptions for data items that may appear on the form. These schemas also contain simple data validation rules.
      .js Contains JScript code that responds to form events and performs other tasks. Code may also be written in VBScript.
     .xslTransforms data into different views, such as summary and detail.


    InfoPath modifies the component files shown in Figure 7-11 and described in Table 7-1 whenever you work with the form template in design mode. In other words, InfoPath is a visual editor for XML, XSD, and XSL files, although those files are stored in the compiled form template (.xsn).

    It is instructive to create a simple template and then extract and examine the generated form files. The INFREF.CHM Help file that ships with InfoPath includes descriptions of the elements and attributes used in template component files. Reading these generated files is akin to examining recorded VBA code in Excel.

    7.1.5. Some terminology

    Before we go too far, I'd like to define a few terms InfoPath uses frequently:


    Form template , or just template

    The .xsn file that InfoPath uses to generate a form.


    Form data file, or just form

    The InfoPath .xml document associated with a form template. You open a form template in user mode to create a new form data file.


    Design mode, or just design

    How you create or edit a form template in InfoPath. From Windows Explorer, you design a template by right-clicking and selecting Design.


    User mode, or just open

    How you create or edit a form data file. From Windows Explorer, you create a new form data file by double-clicking the template (open is the default action).


    Views

    What is displayed by a form. One form may have different views - typical examples are detail and summary views or query and result views.


    Primary data source

    The data that the form is based on. That can be an XML file, database, or a Web service.


    Secondary data source

    A data provider used to populate controls such as list boxes, and to provide values otherwise used by the InfoPath form.


    Actions

    Predefined tasks that InfoPath associates with certain controls and menu items. For example, the Button control can have a Submit action that updates a database.


    Rules

    In SP1, rules provide a way to combine actions in a sequence or set conditions under which an action should occur. Rules and actions provide a way to accomplish tasks that would require programming instructions in most other form tools.

    7.1.6. What about...

    InfoPath uses the Task pane to display Help. This is sometimes slow and difficult to navigate, and is virtually useless for programming topics. You can get better Help from the following Help files installed with InfoPath.

    To get Help onLook here
    Using InfoPath C:\Program Files\Microsoft Office\OFFICE11\1033\InfMain.chm
    Programming InfoPath and understanding form template components (.xsf, et al) C:\Program Files\Microsoft Office\OFFICE11\1033\InfRef.chm




    Excel 2003 Programming. A Developer's Notebook
    Excel 2003 Programming: A Developers Notebook (Developers Notebook)
    ISBN: 0596007671
    EAN: 2147483647
    Year: 2004
    Pages: 133
    Authors: Jeff Webb

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