InfoPath for Smart Clients, Browsers, and WinForms

I'm posting this as we go through the Q&A portion of this presentation, which covered both InfoPath development, and InfoPath's capabilities in publishing and interacting with different environs. InfoPath forms can now be used both inside MS Infopath ("smart client"), over a browser, or embedded in other apps. Here come the notes...

 

Importing Forms

An importer will automatically recognize and convert Word docs. It recognizes certain patterns, like a text box for a multi-line form, and a repeating table for tables with headers.

 

You can create an MSI installer from inside InfoPath.

 

You can publish a form either into a DocLib, or as a ContentType in SP. At publish time, the xsd is converted into something that can be rendered directly to a browser.

 

When you create a new instance with New, if the client is a smart client, InfoPath will open. You can also open the browser version directly, and the experience is identical in both.

 

There is an Importer Framework which you can extend with custom importers to migrate existing templates and data. Out of the box, there are importers for Word and Excel. The interface is IFormTemplateConverter for forms, and IInfoPathDataImporter for data.

 

Template Parts

You can now re-use sections and logic with Template Parts. This supports auto-updating sections and logic across solutions. It supports formatting and control properties, main data source and secondary data connections, rules and other BL, conditional formatting, and formulas / calculations. A drawback is that this doesn't include code, and the recommendation is that you put code into ActiveX controls.  The control toolbox has a Custom section where these Template Parts can live and be dropped onto the design surface.

 

The Template Part design environment is identical with the InfoPath designer, but filtered to provide features specific to a section (i.e. no roles, etc.). As an example, you could create a Qty Item Description Cost table with a Totals row at the bottom and re-use this as a Template Part across your forms. In the designer, you wil be notified when the source Template Part is update, and you have the option to right-click and select Update to bring in the changes.

 

InfoPath Business Logic

A goal of infoPath design is that code should not be required in the majority of solutions.

 

InfoPath is now fully managed (CLR 2.0). MSXML is gone, they've finally moved to use System.Xml. The development experience is much better (events fire once per change, forms accept input parameters, and you have Preview with Full Trust. The caveats are that this is a new object model. There  are tools to migrate managed code, but the move from MSXML to System.Xml means some manual changes will probably be necessary. That said, you don't need to migrate forms unless you want the browser support. If using the Smart Client, you can continue to use all your existing forms as-is.

 

VS Integration

Visual Studio for Applications is an IDE for the masses and it's included in InfoPath (similar to the old built-in IDE). Visual Studio Tools for Office is an embedded designer for professional devs. It provides a single IDE for all projects (Workflow, etc.).

 

The Visual Studio Tools for Office experience is richer, for example you get full debugging support to trace form events.

 

When presented through the browser, validation will happen during a round-trip after an update, and the view is immediately refreshed to display any errors. This uses XMLHTTP, as its development preceeded Atlas.

 

Deployment and Security

The two questions to ask: Does my form use data connections, and does my data contain code? Based on these, you can decide which trust level to use: Restricted, Domain, or Full Trust.

 

If you don't use data connections, Restricted (the default) is fine. For example, this would be a form you might pass around by e-mail.

 

If you require connections in the same domain or over a trusted connection, or if the form contains code, you can use Domain trust. An example would be a form deployed to SharePoint.


If you require cross-domain connections, or need to run code locally, you would require Full Trust and either install a Smart Client, or sign the deployment.

 

Custom Task Panes and Add-Ins

You can add custom functionality to InfoPath and re-use this functionality across Office. The interfaces are IDTExtensibility2 and Istartup. For Custom Task Panes, it's ICustomTaskPaneDesigner.

 

Hosting InfoPath Inside Your Application

There are WinForms and ActiveX controls which you can embed in an application. For example, property editors, or workflow dialogs. There is an analogous aspx control to host browser forms. The ActiveX however is not recommended for browser deployment (use the normal SharePoint / browser deployment for browser forms), and some features aren't available like ink control.

 

In WinForms, this appears as the FormControl in the toolbox. You basically add a FormControl to the design surface, add code (e.g. during the Form Load event) to initialize the embedded form with the location of the xsn (FormControl1.NewFromSolution(@"c:\myForm.xsn"), and that's it. The host application also has acess to data inside the form via the InfoPath Object Model (OM). For example, FormControl1.XmlForm.Errors.Count. All of InfoPath's commands are accessible via ILACommandTarget (sp?). For example, you could create your own toolbars which call InfoPath functions on the embedded form, and you can combine this with access to the OM for some pretty powerful interop. 

 

 

No Comments