📜 ⬆️ ⬇️

Electronic forms via Microsoft InfoPath

Hi, habravchane!

image
Business processes and workflow in any organization require the filling of a variety of forms and forms. The task of automating these processes involves, inter alia, replacing the antediluvian paper forms with electronic analogues. It uses a lot of very different tools and technologies: forms based on Excel documents, forms based on Access, web forms of asp.net applications, corporate desktop applications.

As part of the MS Office package, there is a program specifically designed for creating electronic forms - this is Microsoft Office InfoPath.
')
I will talk about the basics of developing InfoPath forms. The focus will be on basic things, but in conclusion, some deeper aspects will be mentioned, such as data connections, programming in InfoPath forms and integration with Sharepoint.



Concept


The underlying principle of InfoPath forms is the separation of a form template and its data.

In accordance with this division, InfoPath appears in two ways: the designer for developing templates and the client for opening and filling out forms based on templates. Up until InfoPath 2007, this functionality was combined in one application. In the version of Office 2010, the application is divided into two independent components: InfoPath Designer (Form Designer), designed to develop templates and InfoPath Filler, which fill out specific forms based on templates. Examples in this article will be for InfoPath 2007.
Typically, a form template is published in a well-known place from where it can be accessed by users. Users open a template and fill out a form. Further actions may be different: saving the completed form as an .xml file, sending information somewhere.
Saved as a .xml file, the form can be opened and modified. It is clear that the .xml file must “know” where the corresponding form template is located, because the structure and design of the form are defined in the template. If the template is not available, InfoPath will take it from the cache, if it has changed, you will be given the opportunity to download the updated template. To provide links between a form template and its data, InfoPath has a complex architecture for publishing form templates.

Simple example


The best way to figure it out is to touch it with your hands. For a start, you can experiment with the ready-made “sample” forms with the program. Open Microsoft Office InfoPath 2007. If the Getting Started window appears, select “Set up sample” on the left, if it doesn’t appear, go to the “File” menu, select “Form Designer ...” and in the window that opens, again click on the "Customize Pattern ..." button to the left. Take, for example, the sample "Asset Accounting".

image

After double clicking on the sample, InfoPath will open it in designer mode. You can edit the form template, delete unnecessary fields, add new ones, etc. The panel with the available components (input fields, checkboxes, drop-down lists) can be opened via the “Controls” link on the taskbar in the right part of the window.

image

Let's save our template in a convenient place as the “Asset Accounting.xsn” file. Perhaps at the same time InfoPath will remind you that it would be good to publish it - but for now let's not do it.

image

Now you can open the template and fill out the form.

After filling, you can save it. This will already be a file with the .xml extension - a data file based on our template. This way you can fill out many forms based on one template.

image

Publication


As already mentioned, InfoPath has a complex architecture for publishing form templates. The asset accounting form template, which we have saved somewhere on our computer, is available only to us. I would like to make it accessible to a larger circle of users.

First, open the form template in design mode (the “Designer” item from the context menu of the file).
The Publish Wizard is launched by the "Publish ..." command from the "File" menu.

InfoPath provides several options for publishing a form. In this case, let's lay out the template in a shared folder.

image

In the next wizard window you need to specify the place of publication. At one time I suffered at this step. Not quite understanding the meaning of the actions performed, I clicked on the “Browse” button and selected the saved template file there. This is not necessary. In the "Path and file name for the form template" field, the path to the file that does not yet exist should be indicated in the place where we want to publish it. Therefore, click "Browse", we reach the shared folder, and in the "File name" field we drive in the name of the future published template, and then click "OK".

image

image

image

In the next step, you need to enter an alternative way to access the published template from the users. After all, the mapping of network resources may differ from the developer and the end user. The network resource seen by end users may be different. And InfoPath requires that access to the published template is uniform. Therefore, when publishing, two paths are specified — one for the administrator (we have already defined it), and the other for the end users. If the path on the part of the user is no different, simply copy the path that we indicated in the previous step into the input field.

image

After clicking on the “Next” button, we check the entered data and click “Publish”.
In the final wizard window, you can enjoy the message about the successful publication and ask to immediately open the form based on the published template in order to make sure that everything is in order.

image

Security


In the final windows of the publication wizard you can see the line “Security level: Domain”.
The security level of a form determines what form is allowed to do, what is the level of trust in it.
This is set when developing a form template on the “Security and Trust” tab of the “Form Settings” dialog box, which is opened by the same command from the “Tools” menu. There are three possible levels of trust: limited, domain level and full trust.

By default, the “Automatically detect security level” checkbox is selected on the Security and Trust tab. From experience, I can say that it is automatically determined by far not always automatically: a significant part of errors when opening a form based on a certain template was caused precisely by the fact that the template had a low level of security.

Little by little


Data sources

As already mentioned, the InfoPath form can access external data sources. This can be a database (MS Sql or Access), a Sharepoint list, a web service, .xml file. The most obvious use is to populate drop-down lists based on various directories.
Let me remind you that the form template that accesses external data sources must have a security level - domain.

In fact, the structure of the InfoPath form itself is determined by the data source. Even if a form template is created from scratch, all the same, there will already be one in the data sources - the “primary” data source. When adding elements to the form, the corresponding nodes will be added to the data source. Any data source in InfoPath is represented by an xml-tree, and thus the structure of the form is essentially an xml-tree.

It is possible to create InfoPath forms based on some of the available data sources - web services, databases, predefined xml schemas. In this case, we will not be able to change the data source, which is the basis of the structure of the form, and we will not be able to add new fields that are not in the data source.

Representation

A form can have multiple views. A view is a kind of “slice” that includes a specific group of fields. After all, it is not necessary to simultaneously display on the form all the fields of its data source. If there are many fields, you can group them by meaning and divide them into several representations. In addition, you can create different views for different user groups that will work with the form as part of a business process. Finally, you can create a separate presentation for printing the form, which will have a particularly beautiful design, focused specifically on this task. You can switch between views using the InfoPath client’s View menu, in which the form is open, and, for example, programmatically, for example, by clicking the buttons on the form (you can, on the contrary, disable the ability to manually switch through the View menu ).

Programming

Complex forms can contain program code (managed code in C # or Visual Basic .Net is of most interest). Let me remind you that the level of security of such forms should be “Full trust”. In the code, you can, for example, perform the necessary event processing, complex control of the input data (in addition to simpler validation, which can be configured through the InfoPath designer interface). It is possible to dynamically change the interface and form elements, add and hide certain input fields, switch between views. You can programmatically connect to such data sources, connection to which is not provided in the InfoPath constructor (for example, to an Oracle database).

Sharepoint Integration

A bunch of InfoPath forms and Sharepoint is probably one of the most promising and widespread applications of InfoPath forms today. Let's say my acquaintance with InfoPath happened quite recently in the process of studying the development of workflows (Workflows) for Sharepoint. For many years before, InfoPath lived quietly on my computer as part of the MS Office suite, without attracting attention to itself.

So, what about InfoPath integration with Sharepoint?


Afterword


In this article, I tried to briefly describe the development of electronic forms using InfoPath, focusing mainly on the Microsoft Office version of InfoPath 2007. Many questions are mentioned only in passing, other aspects remained completely unaffected - primarily because I myself encountered InfoPath- forms are relatively recent and the process of studying them is far from complete. This process could be much more laborious without one book, which served me as the main source of information on the topic - this is Phil Janus' book “InfoPath 2007 for Professionals”.

Source: https://habr.com/ru/post/111333/


All Articles