Académique Documents
Professionnel Documents
Culture Documents
RATE THIS
infopath1
22 Feb 2006 3:45 PM
9
First Id like to mention that, as part of a recent announcement, the product name for InfoPath 12 is
Microsoft Office InfoPath 2007. This is the name Ill be using from now on in my blog. In my first post I talk
about the benefits of browser-enabled forms. Id like to focus now on the InfoPath rich client and give you
a sense of how it can streamline your daily work with InfoPath e-mail forms. If you are familiar with
InfoPath SP1 you probably know that it already allows you to send forms as attachments in email. So why
is e-mail forms a new feature in Office InfoPath 2007? Well, the limitation in InfoPath SP1 is that forms
are just regular attachments and they are not integrated in your Outlook email environment. So in Office
2007 weve decided to make forms a first class item in Outlook. That means forms can now be viewed,
edited, saved, and forwarded similar to email messages, meetings, or tasks. In addition, e-mail forms can
leverage Outlook PIM features like categories and follow up to add a new dimension to your forms
workflow. E-mail forms now have their own folder type and they even have their own icon . This tighter
integration makes it really easy to work with forms and to leverage all the structured information they
provide without having to leave your familiar Outlook environment. Lets walk thru a short scenario using
InfoPath e-mail forms.
Lets assume I need to collect information about the computers used by my team. First I need to design a
form template to collects this information. For our scenario, InfoPath ships out-of-the-box an Asset
Tracking template, which I will use for this example. In order to be sent out safely in email, forms like
Asset Tracking need to work only with data from within the form and can contain only declarative logic, no
code. Because of these security restrictions we call such forms restricted forms. Once the template is
completed, I need to deploy it using the Publishing Wizard and selecting the option to a list of e-mail
recipients. I then need to specify the recipients, add an optional comment, and send out the form. The
screenshot below shows the e-mail deployment of my Asset Tracking form:
When a member of my team receives the form, she clicks Reply, which opens the form in InfoPath. She
then fills out the computer information and sends the completed form back to me, as shown in the
screenshot below. She has the choice to send me an editable XML form, which is the default, or to send
back just a read-only view. She can also add a comment related to the form in the Introduction field. This
comment is in fact metadata that travels with the forms. The same field can be used, for example, to ask
her assistant to fill out the asset information for her and, for more complex forms, to give instructions on
how to complete the form. Here is an example of a completed asset tracking form (In this case Ive
completed it as a team member and Im sending it back to myself):
Note that at design time I could include a submit button in the form. This will let my team members
double-click on the form, edit it in InfoPath and then click Submit to send it back to me in e-mail, same
as if they replied. However, Submit will validate the form and will enforce the return e-mail address. This
helps if I need to implement a more formal workflow process using e-mail forms.
Now Im switching back to being the data collector. Im expecting to receive a fairly large number of e-mail
forms from my team and I want to be ready to process them. To this end, Im setting up a new Outlook
folder to collect the asset data. I right click on Mailbox and select New Folder. In the New Folder dialog
I need to select the option InfoPath Form Items, which is new in Outlook 2007, and associates the folder
with InfoPath forms. Here is the dialog that creates the assets folder for e-mail forms:
Once Ive created the folder, I can also create a rule that automatically routes incoming asset forms to this
folder. This rule should refer to InfoPath forms, as shown in the Rules Wizard dialog below. Then I need to
pick-up the specific form type out of the list of all the templates that have been cached on my local
machine. For each incoming message, the rule will check if it is an e-mail form of type asset tracking
and will route all the matching e-mails to the assets folder.
Note that forms can be stored in any Outlook folder. However dedicated forms folders will create by
default a new e-mail form based on the template associated with the folder. In addition those folders will
allow property promotion, as explained below.
When each form is saved into the assets folder, the properties that have been market for data promotion
in the template are copied as Outlook properties. The forms in this folder can now be sorted and filtered
based on their promoted properties, You may know how useful it is to take advantage of promoted
properties in SharePoint form libraries. You can see at a glance the work progress captured in weekly
status reports or the results of a team survey. The same experience is now also available on your local
machine, using e-mail forms and form folders in Outlook. Like in SharePoint, the data stored in form
folders can be aggregated and exported to Excel for further processing. Below is an example of asset
forms with properties promoted in the assets folder:
As you can see, in addition to using the properties promoted from forms, I can take advantage of
other properties, like Categories and Flags that Outlook provides for all item, regardless of type. In the
example above Ive flagged the machines that need to be replaced, upgraded, or the new ones that have
been purchased in the last quarter.
When I get all the replies from my team, I will go ahead and process the data. As I mentioned before, the
data is not in some collection of text e-mail messages that I need to read in order to extract information for
my report. It is in a collection of structured forms that I can very easily process and extract the data to
report on.
My next step is to export the data to Excel. I select all the forms in the folder and then select the Export
to Excel option from the toolbar. This option automatically generates a spreadsheet with all the data
mapped from the forms into Excel. Note that the export to Excel is not limited to the promoted properties
in my folder but rather to the entire XML of each form in the folder. Once I have all the data in Excel, I
create a simple pivot table with the number of laptop, desktop, and lab machines for each functional team
and then I chart the data using the new graphics engine. Here is the result of my data gathering scenario
using the e-mail form for asset tracking:
The data needs to be structured otherwise youd just use regular e-mail
The data collection is done ad-hoc theres no need to set up a more formal process
You own the final results it is ok for the final results to be collected in your own mailbox
Once you have the replies, you could process them as needed and/or share the data with your team. In
our example, I am the consumer of the collected information. I will export the data to Excel, review it, and
order new hardware as necessary. For status report, the team lead will be assembling the report, then will
publish it, and present it to the team.
A broader scenario is using e-mail to make other forms available to your users. Your forms could be part
of a formal team scenario like tracking weekly status, a department workflow solution, or an enterprise
wide line-of-business application allowing every employee in the company to update benefits or to submit
their performance reviews. In all these scenarios, the forms can be delivered, filled out, and submitted in
Outlook. We will cover integrated scenarios for e-mail forms in a follow-up post.
Finally an important benefit of e-mail forms is offline filling. As you may know, form templates are
automatically downloaded on your machine on first use. Forms can also be installed as part of a client
setup. Once youve used a form once on your machine, you can fill out any similar forms offline. To make
things even simpler, restricted form templates can be included in the same message with the actual email form. A user can download the form in Outlook, open it, fill it out, and submit it back as e-mail form.
An additional benefit here is that you can complete the form offline, submit it, and be done. The form will
be stored in the Outlook Outbox folder and will be sent out automatically next time Outlook connects to
your e-mail server.
I hope Ive been able to give you a sense of the value of InfoPath e-mail forms as first class items in
Outlook and get you interested in trying them out in Office 2007. Ill follow up shortly with other posts on
new InfoPath features. Stay tuned! Id also love to hear your thoughts and feedback.
InfoPath 2007
This article is based on a prerelease version of the 2007 Microsoft Office system. All information
herein is subject to change.
Contents
InfoPath Forms Services
Design Once
Template Parts
Document Information Panel
Hosting the InfoPath Form Control
Importing and Exporting Forms
Managed Object Model
Visual Studio Integration
InfoPath 2007 is an XML forms designer and editor package in the 2007 Microsoft Office system.
Now in its third iteration (if you include InfoPath 2003 Service Pack 1), InfoPath has matured into
a fully featured and integrated member of the Office family. In this article, we give you a sneak
peek at some of its highlights and new features.
InfoPath 2007 includes a new Design a Form dialog (see Figure 1) that simplifies the process of
designing form templates. You can also build Template Parts (reusable components you can insert
into multiple form templates) as well as browser-enable your form templates and Template Parts.
Browser-enabled forms are designed in InfoPath and can be filled out either in InfoPath or in a
Web browser. Browser-based forms are hosted using InfoPath Forms Services from Microsoft
Office SharePoint Server 2007.
InfoPath features are available and some will be limited in their functionality in the Web browser.
As we'll see, the few limitations that exist allow the same form to be used in InfoPath and Forms
Services without any modifications. We call this "design once," and we'll review the concept in
more detail in the next section.
Let's design the Status Report sample form under the Customize a Sample link in the Design a
Form dialog shown in Figure 1. This form is already browser enabled, so all we need to do is
publish it to a server running InfoPath Forms Services. To do so, click on the Publish Form
Template link in the Design Tasks task pane. This brings up the Publishing Wizard, with various
options for publishing forms. In this case, we're publishing to a SharePoint Server with InfoPath
Forms Services. Subsequent wizard steps ask which server to use for publishing, whether you
want to create a SharePoint document library or content type, and what form data (if any) to
promote as columns in the library or content type. The last page offers a link to the library where
we've published our browser-enabled form template. From there we can fill out our Status Report
form.
Simply clicking the New button in the document library creates a new Status Report form. By
default, the form will open in the InfoPath client application if it's available. That's because
InfoPath is the preferred client for form filling (though there's a setting in the library to default to
the browser). If InfoPath is not available, the form will render in the browser automatically. Figure
2 shows a filled-out form in InfoPath Forms Services. Notice that browser forms support rich text
editing (as seen in the Summary field) with the Rich Text Box control. For comparison, Figure
3 shows the exact same Status Report filled out in the InfoPath client application.
Design Once
Design once means you can create a form template that will work properly within both the
InfoPath application and a Web browser. There's no need to decide ahead of time whether the
form should target rich client or browser-based users. If you do choose to design a form
specifically for the InfoPath client (and therefore not browser enabled), InfoPath exposes an
extended set of features. Controls such as the Combo Box, User Roles, showing message boxes
through a rule action, and the custom task pane are some of the extra features you'll see.
There are classes of features that don't work with Forms Services: unsupported and incompatible.
If you include unsupported features (such as message boxes and custom task panes), you can
still use the form template in Forms Services, but those features are nonfunctional. Incompatible
features, in contrast, will fail when published to Forms Services.
How do we know which features are compatible and which are not? The Design Checker, shown
in Figure 4, is a new task pane that communicates potential design problems to the developer.
For this example, we designed a complex form that is not browser enabled. To make it compatible
with Forms Services, we clicked on the Change Compatibility Settings link and modified the
setting that enables the form to work in either a browser or in InfoPath. The Design Checker
displays errors because our initial design included InfoPath client-only features, such as two
Master/Detail controls that are incompatible with browser-enabled forms. When designing a
browser-compatible form template, such features are not even available in the user interface. To
begin fixing the errors, you simply click on the error to jump to the invalid control. If an error is
not on a control, InfoPath gives instructions on how to proceed.
Template Parts
Custom controls were introduced with InfoPath 2003 Service Pack 1 (SP1), but support was
limited to ActiveX controls. Since ActiveX controls have been around for over 10 years, there are
plenty to choose from. But only controls safe for scripting and initialization can be used in
InfoPath form templates. And even those that are safe may not work correctly in InfoPath. If you
don't find an existing ActiveX control that fits your needs, you can always create your own. This is
time consuming, though, and requires in-depth knowledge of ActiveX technologies.
Luckily, InfoPath 2007 introduces Template Parts, which let you build custom components without
code. As the name implies, Template Parts allow you to reuse parts of one form template in other
form templates without having to rebuild each one from scratch. Let's say you have an XML
schema that includes customer information such as name, address, phone number, and so on.
You want to build a set of forms all based on the customer section of the schema without having
to recreate the controls and schema that pertain to the customer information in each form
template. With InfoPath 2007 you don't have to recreate all those controls.
When you design a form template in InfoPath 2007, you now have the option to create a Template
Part instead of a form template, as the new Design a Form dialog in Figure 1 shows. You can
create a blank Template Part just as you'd create a blank form template, or you can base your
Template Part on an XML schema that includes customer information.
Once you specify Template Part in the Design a Form dialog, InfoPath opens in design mode. From
here, the process of creating your Template Part is almost exactly the same as creating a form
template. The only difference, as when creating a browser-enabled form template, is that not all
features are available. Those features not supported in Template Parts simply aren't available in
the user interface in design mode. For example, you can't add custom code to Template Parts so
the Programming menu item is not available on the Tools menu.
Once you've created a Template Part based on the XML schema that contains customer
information, you can insert controls that are bound to the customer information in the schema.
And just as you normally would when designing a form template, you can add data validation,
rules, calculated default values, and data connections. When you're finished, you save it as you
normally would. This creates a file with an .xtp file name extension. (The .xtp file is similar to
the .xsn file created when you save a form template.)
Before you can use your Template Part in form templates, you must install it into the InfoPath
Controls task pane in design mode using the Add or Remove Custom Controls wizard. After the
Template Part is installed, it is available in your Controls task pane just like any of the built-in
InfoPath controls, and you can insert it into as many form templates as you wish.
As with the built-in InfoPath controls, when inserting a Template Part into a form template, the
schema structure that pertains to your new control will be created automatically in the form
template (if you have selected the Automatically create data source option in the Controls task
pane) or you can choose to bind your control to an existing schema structure. Any of the features
you added to your Template Part earlier, such as data validation or rules, will be automatically
added to your form template. Template Parts not only enable you to create your own custom
controls without writing code, they also give you a way to share parts of a form template across
multiple form templates, thus saving much time and effort.
host in your app. Support for hosting InfoPath in both managed and unmanaged code is provided
so you can choose the technology you want to use to build your application. Obviously, hosting
any ActiveX control in an unmanaged application is more complicated than in a managed app.
However, if you already know how to implement an ActiveX control host application, doing so
with the InfoPath ActiveX control is no different.
Let's take a brief look at how to host InfoPath in a managed Windows-based application using C#.
(Any InfoPath-specific concepts we discuss can just as easily be applied to unmanaged
applications and to other managed languages.)
After stepping through the New Project wizard in Visual Studio 2005 to create your Windowsbased application in C#, you'll need to add the InfoPath form control to the Visual Studio toolbox
before you can use it. To do so, click on Choose Toolbox Items from the Tools menu, click on the
.NET Framework Components tab, and then locate the component named FormControl in the
Microsoft.Office.InfoPath namespace. (In unmanaged code, the FormControl class is equivalent to
the IInfoPathEditor interface.) Once the InfoPath form control is in your toolbox, you can add it to
your Windows form just as you would with any other control.
If you build and run your application at this point, the InfoPath form control will be instantiated
but it won't do anything useful. Most likely you'll want the InfoPath form control in your
application to load a form. If you look at the FormControl object in the Object Browser in Visual
Studio 2005, you'll see that the InfoPath form control provides a number of useful methods and
properties. Probably the most important methods available are the ones that let you load a form
into the InfoPath controlOpen and NewFromFormTemplate.For the purposes of this simple
example we'll use one of the two NewFromFormTemplate methodsthe one that takes the URI of
the InfoPath form template you want to load as a string parameter. For example, if you want to
load a form template containing customer information, you could do so by adding the following
code:
formControl1.NewFromFormTemplate(@"\\mysharelocation\customerInformation.xsn");
Alternatively, if you want to load an existing form, you could use the open method, like so:
formControl1.Open(@"\\mysharelocation\myForm.xml");
Note that the XML file you pass to the open method must be a valid InfoPath form.
The XmlForm property is equally useful. (In unmanaged code it is equivalent to the
get_XDocument method on the IInfoPathEditor interface.) This property gives you access to the
entire InfoPath object model for the form. Certain objects in the InfoPath object model, such as
the Application and Window objects, aren't available when hosting the InfoPath control. These
objects pertain to the InfoPath client application, so have no meaning when hosting the InfoPath
form control.
The methods and properties available on the FormControl object give you a few ways to manage
and interact with the hosted InfoPath form control. But this object obviously doesn't provide full
control over the hosted form. For example, how do you make text bold or italic in the form? How
do you insert a table into a RichText Box control? These and other features that are available in
the InfoPath client application through the user interface aren't available through the FormControl
object. However, you can access virtually all of these features from your own applications, using
the IOleCommandTarget interface.
In unmanaged code, using IOleCommandTarget is straightforward. You simply obtain a pointer to
the interface from the hosted control and then pass a command to the Exec method (Likewise,
you can call the QueryStatus method to see if a command is currently supported.) In managed
code, you must use COM interop to access the interface. To find a list of all the available
commands simply look at the FormControlCommandIds.CommandIds static helper class in the
Microsoft.Office.InfoPath namespace. (In the Object Browser in Visual Studio, the
FormControlCommandIds.CommandIds is listed under the Microsoft.Office.InfoPath.FormControl
namespace. There are literally hundreds of commands that enable you to control hosted forms
from within your application.
With the support for hosting InfoPath in managed applications, you can create a simple hosting
application in literally just a few minutes. You can also host the InfoPath Forms Services
component. A form in the browser can be rendered by hosting the XmlFormView ASP.NET control
in an .aspx page. (The XmlFormView class is defined by the Microsoft.Office.InfoPath.Server.dll
assembly in the Controls namespace.) In fact, when you fill out a form in the Web browser that
isn't hosted, you're really looking at a mostly empty .aspx page that hosts the XmlFormView
control.
To use this control in your own ASP.NET page, your page must live on a SharePoint Server 2007
server that is running Forms Services. Then you can use Visual Studio 2005 to add the control to
the Toolbox (as described earlier for the InfoPath Form Control) and insert it into the Visual Studio
design surface of your ASP.NET Web site project. As you code against the XmlFormView control,
you might notice that the entire InfoPath object model is available to the host page. This is a
faade, though, because only a strict subset of the object model is actually allowed to be called
by the hosted page. For example, the data source is accessible through the MainDataSource
property, but accessing the form's Errors collection is restricted. An exception is thrown when
calling any restricted properties and methods at run time.
Hosting a Web Form in the browser is another exciting prospect for your InfoPath forms. Not only
can you reach out to users without InfoPath, you can also integrate the InfoPath form-filling
experience into your own Web pages while maintaining the integrity of your Web site's
appearance.
In this case, users know they are supposed to enter their name in the underlined area of the
document. InfoPath will detect this construct and create a Textbox control in the view. That
Textbox control will be bound to a field element in the schema. The fact that the built-in InfoPath
importers create controls and schema will certainly save you lots of time when you're migrating
forms from Word and Excel to InfoPath.
InfoPath 2007 also provides tight integration with Outlook 2007. You can publish a form template
in InfoPath 2007 to a list of e-mail recipients. This gives you a quick way to distribute a form
template to accomplish simple tasks such as gathering survey data. When Outlook 2007 users
receive the form, they can fill it out from within Outlook without having to open the InfoPath client
application. Figure 6 shows an InfoPath e-mail form that will collect survey data.
There have been some name changes: the old OnLoad event is now named Loading, and all XML
events have been renamed to Changing, Validating, and Changed. Also, the InfoPath 2007 data
source is exposed in code as an XPathNavigator instead of MSXML's XML document and node
interfaces. This change provides a performance-oriented cursor-based approach to working with
the underlying form data. (To get the main data source navigator, use
this.MainDataSource.CreateNavigator.)
Many objects that were grouped in thisXDocument are now inherited members, and some even
sport updated names (such as the MainDataSource member). A few others include CurrentView,
DataConnections, DataSources, Errors, and SignedDataBlocks. One of the more popular methods
to use in form code was to display a dialog using:
thisXDocument.UI.Alert("message")
Now you'd use the System.Windows.Forms namespace's MessageBox class. By calling the static
method Show off of the MessageBox class, you can show the same dialog as the old Alert
method. Better yet, Show also has overrides to use message box captions, buttons, and even a
custom icon.
Best of all, the InfoPath object model abides by the design-once philosophy we talked about
earlier: the code you write behind your form can be used on both the client and server.
Figure 7 Designing an InfoPath Form with Visual Studio Tools for Office
Besides the integrated design environment, there are other benefits to using Visual Studio Tools
for Office. They include being able to use multiple simultaneously visible task panes, the Visual
Studio Find and Replace functionality, and taking advantage of plug-ins such as Visual SourceSafe
for source code control when collaborating in a team setting.
The topics we've discussed are just a few of the highlights of InfoPath 2007. We hope this brief
introduction will spark your interest and will prompt you to explore InfoPath 2007 further. If you
are new to InfoPath or would like more detailed information about designing forms, see the
InfoPath Web site atoffice.microsoft.com. Tune in to the InfoPath Team Blog
at blogs.msdn.com/infopath for info from the product team.
In this article
Prerequisites for using InfoPath e-mail forms
Collect data from others by using an InfoPath e-mail form
Submit your own data by using an InfoPath e-mail form
Installation prerequisites for recipients If the recipients of your InfoPath e-mail forms do not have
Microsoft Office Outlook 2007 and Microsoft Office InfoPath 2007 installed and configured to use InfoPath email forms, they will receive an e-mail message that contains an HTML representation of the default form
view, and an InfoPath form will be attached to the e-mail message. If the recipients have an earlier version of
InfoPath installed, and the form contains backward-compatible features, they can save the attached form file
and open it by using the earlier version of InfoPath.
NOTE When the InfoPath e-mail forms that you send to others are filled out and sent back to you, you can
review the data from those forms in various ways in Office Outlook 2007. For example, you can view the data
by using a customized view of an InfoPath Forms folder, which enables you to view the form data without
opening the forms themselves. You can also merge multiple InfoPath e-mail forms into a single form to
analyze or compare data, or export the data from one or more InfoPath e-mail forms to Microsoft Office Excel
2007. Find more information about these tasks in the See Also section.
Top of Page
On the File menu, point to New, and then click Choose InfoPath Form.
2.
In the Choose InfoPath Form dialog box, double-click the form that you want.
3.
4.
Enter recipient e-mail addresses in the To and Cc boxes. Separate names with a semicolon (;).
NOTE The Bcc box does not appear by default. To add an e-mail address to the Bcc box, click To or Cc, and
then in the dialog box that appears, type the e-mail address in the Bcc box.
5.
In the Subject box, type a new subject for the message.
6.
In the Introduction box, type explanatory text about the InfoPath e-mail form.
7.
network folder or a Windows SharePoint Services 3.0 site, select the Include form templatecheck box.
To send a read-only version of the form, click Read-only snapshot.
8.
Click Send.
NOTE Because you are sending an InfoPath e-mail form to collect data from others, you do not need to type
any data in the InfoPath e-mail form fields before you send the form.
Top of Page
On the File menu, point to New, and then click Choose InfoPath Form.
2.
In the Choose InfoPath Form dialog box, click the form that you want.
3.
In the InfoPath Form: Form Name window, type data into the InfoPath e-mail form.
TIP Filling out an InfoPath e-mail form is just like filling out a form in InfoPath. For example, if the form
contains more than one view, you can switch views by clicking the View menu on the form and then selecting
the view that you want. Find more information about filling out InfoPath forms in the See Also section.
4.
Click Submit, and then in the InfoPath Form: Form Name dialog box, type the recipient e-mail
addresses in the To, Cc, or Bcc boxes. Separate names with a semicolon (;).
NOTE If the form template designer has defined a custom submit action, the data is automatically sent.
5.
6.
In the large box at the bottom of the dialog box, type explanatory text about the InfoPath e-mail form.
7.
Click Send.
8.
To save a copy of the form that you just sent to the active folder, click Save on the File menu.
Mel Balsamo
Using InfoPath E-mail Forms to Communicate with External Users
Gregs blog post provided brief guidelines on how to create form templates with different versions. One is a
restricted version for public-use, i.e. for external users; the other is a version for private use. The private version
may contain some additional controls that allow you to do more with your forms, such as submitting them to a
SharePoint document library.
This technique gives us the power to use InfoPath forms to capture offline e-mailed data for centralized SharePoint
upload. We can email forms back-and-forth, to and from external users (sometimes offline or disconnected), and at
the same time, manage those forms in private locations such as a SharePoint site. We need to make sure that the
form data in both the public and the private locations are in-sync.
This blog post details the steps to setup a sample email form template with two different versions: Public and
Private.
Heres a diagram of the scenario were trying to accomplish:
1. You email the form template (XSN) file to an external user (Public version Ver. 1).
2. External user (sometimes offline) opens the form template, fills it out and emails back to you.
3. You receive the form (XML) and open it with the higher version of the form template (Private version Ver. 2).
Note that you may receive a warning message that the form template associated with the form has a higher
version than the one stored on your computer. Clicking Yes will open the form with your latest version.
4. You submit the form to your SharePoint document library.
5. You open the form from SharePoint, edit it and email it back to the user.
6. User receives the form, accepts the changes, re-edits and re-emails back to you.
Note that the user may also receive a warning message about the form template version. Clicking Yes will allow
user to open the latest form.
7. You receive the form and re-submit it to SharePoint.
Sounds interesting? Lets get started
REQUIREMENTS:
InfoPath 2007
Outlook 2007
SharePoint Library
PUBLIC VERSION
1. Add the following fields to your main Data Source
Make the EmailAddress field required, so we know where to send the form back.
2. Add a layout table in your template, and drag the myFields node onto your table as Controls in Layout Table.
Expand your controls as necessary to make them fit in your table.
3. Double-click on your Date field to open its properties.
a. Under the Data tab, click Format. Select any format for the time such as:
b. Click OK.
c. Back in the Data tab, click on the fx icon beside the Value field, and enter the now() function in the formula box.
This will ensure that well have a unique date value every time we fill out a form the first time. We will specify this
unique value as the form filename in our SharePoint library later.
d. Click OK to close all the dialog boxes.
4. Allow the Comments field to display multi-line in the Comments field properties > Display tab, just so theres
more space for users to fill it out.
e. Click Next.
f. Select the option Send the form data as an attachment.
g. For the attachment name, combine the Name and the Date values. Click on the fx button beside the Attachment
Name field, and enter concat formula as seen in the following image, making sure that the underlined fields are
from your main data source:
h. Click OK (no need to attach the form template in the email), Next, then Finish to exit out of the wizard.
6. Add and configure a Submit button.
a. Add a button at the bottom of your table, and double-click to open its properties.
b. In the Button Properties windows General tab, select Submit in the Action dropdown, and click Submit Options.
c. Check the box Allow users to submit this form > Email > Email Submit.
d. Click the Advanced button to expand the window, and select Close the form in the After submit dropdown:
c. Click OK.
PRIVATE VERSION
Next, we will design our private form template. It will have the same fields, so we can just modify our public form
template.
1. While the public template is opened in Design mode, go to File > Save As and save it as PrivateEmailForm.xsn
(to make sure that we are not working on the public version).
2. Modify the Email Submit data connection.
a. Go to Tools > Data Connections and modify Email Submit.
b. Click on the fx button next to the To field and insert the EmailAddress field. This field will contain the external
users email address (where we wish to send the form back to).
f. Click Next, leave the name as SharePoint Library Submit, and then click Finish.
g. Exit out of the Data Connections wizard by clicking Close.
4. Configure the submit buttons.
Note that we now have two Submit data connections, and we therefore need to use two buttons: one that submits
to our SharePoint library, and another to email the form back to the external user. We also need to submit using
rules and specify which Submit data connection to use.
a. Double-click on the existing Submit button to open its properties.
b. In the Action dropdown, select Rules and Custom Code.
c. Label the button Submit to SharePoint and click on Rules.
d. In the Rules dialog, click Add.
e. Name your rule SharePoint Submit and click on Add Action. The action would be to submit using the SharePoint
Library Submit data connection:
b. Click OK.
Heres how our private email form template looks like:
3. To make things simpler and easier to understand, lets remove the date and time stamp in the templates URN:
c. Once again, remove the date and timestamps in the URN to avoid confusion.
d. Click OK.
e. Go to Tools > Form Options > Versioning. Notice that the Version number is something like 1.0.0.x, where x is a
number that automatically increments as we make changes to our template. We can leave it this way for our public
email template.
f. Click OK, then File > Save.
6. Weve already saved the public version as EmailForm; close it, and then send it to an external user by attaching
the form template in the Outlook message.
SEE IT IN ACTION
1. Have an external user fill out and submit the public template you initially emailed.
3. In Outlook, click Open Form. It will open with the private version of the template.
4. Make some changes in the form, such as editing the Comments, and click the SharePoint Submit button.
5. Close the form in Outlook. If you get a warning asking you if you wish to save the form, select No.
6. Verify that the form is submitted to your SharePoint document library.
7. Open the form from SharePoint, make some changes, and email it back to the external user by clicking the
Email External User button.
8. The external user will receive the modified XML and may receive a warning that the form template associated
with the form contains a higher version. Clicking No will allow the user to open the form in Outlook using the public
version.
9. The external user then modifies the form and emails it back to you by clicking the Submit button. Once again, if
you open the received XML in Outlook, it will open with the private version:
10. Re-submit the form to your SharePoint library to make sure you are keeping the latest XML version. It will
overwrite the existing XML in your SharePoint library:
At this point, we should have three form templates in our machine: PublicEmailForm, PrivateEmailForm, and
EmailForm. We are only concerned about EmailForm, as this form template contains the unique Name and ID that
we wish to send back-and-forth, to and from our external users, and manage our SharePoint library forms with.
The PublicEmailForm and the PrivateEmailForm are just temporary placeholders. For instance, if you wish to send a
public version to another external user, we cant send them the latest EmailForm that we have (since its supposed
to be the private version). To do this, we need to open PublicEmailForm in InfoPath Design mode, and re-save
(overwrite) it as EmailForm. After sending to the external user/s, open PrivateEmailForm in Design mode and resave (overwrite) it as EmailForm, and then re-publish to the same SharePoint document library.
Youll realize that were just manipulating the same form template in terms of which version will be sent to public,
and which version should open in our machine.
Once you get the hang of this, it will be easy for you to manage your form data and keep them in-sync no matter
where you publish your forms.
In This Chapter
Add Controls
This chapter shows you how to generate an InfoPath form for use in SharePoint. The following chapters
expand on the functionality and options available. This chapter serves as an end-to-end overall guide to
creating a form and publishing it to SharePoint. Other chapters may cover some details or steps in further
detail.
The first step to create SharePoint forms is to open InfoPath Designer. From there, you have a number of
options. When designing a new form, you have the following template options:
SharePoint List: Use this template to generate an interface for interacting with a SharePoint list. The
generated form can create the actual list in SharePoint.
SharePoint Form Library: Use this template to generate a form library that stores instances of your form from
user input. The content type of this form library is your form template.
E-mail: Use this template to generate a form that can be used within emails.
Blank Form: This is the base web browser form template used to generate SharePoint forms from scratch.
Blank Form (InfoPath Filler): This base client form template is used to generate forms that require users to
have InfoPath installed locally on their computers. The forms created using this template are not rendered in a
web browser.
Database: Use this template to quickly create a form based on a database table from Access or SQL Server.
Web Service: Use this template to generate a form that queries a web service for information.
XML or Schema: This template is used to easily replicate the data structure of an Extensible Markup
Language (XML) file or schema (XSD).
Data Connection File: Use this template to quickly generate a form that uses a data connection file stored in
SharePoint.
Convert Existing Form: The name is confusing because you would think this is used to convert an existing
InfoPath form, but this template actually uses converters to import Microsoft Word or Microsoft Excel
documents and convert them into InfoPath forms.
Document Information Panel: InfoPath now makes it easier to customize input into Office documents based
on SharePoint columns. Use this template to generate the data entry portion of a Microsoft Office document
that is stored within a SharePoint library and contains additional fields for user entry.
Blank 2010 Form: Use this form to create a web-based InfoPath 2010 form.
Blank 2010 Form (InfoPath Filler): Use this form to create a client-based InfoPath 2010 form. Users need
InfoPath 2010 installed locally on their computers.
NOTE
Throughout this book, the terms InfoPath form and SharePoint form may be used interchangeably. A
SharePoint form is essentially a web-enabled InfoPath form with the intention to be able to use the form in
SharePoint.
FIGURE 2.1. The New page provides templates for designing new forms.
To design a simple form, follow these steps:
1.
Click the Click to Add Title text that appears and enter a title for the form.
2.
Click in the bottom section of the form where it states Add Tables.
3.
Click the Insert ribbon bar menu and select the Two-Column 4 table in the Tables section. This is a
layout table that assists in aligning the labels and controls on your form.
4.
5.
Enter a name for the form file and click OK. This saves a local copy of the form.
We now have a base form to which we can start adding controls, as shown in Figure 2.2.
FIGURE 2.2. Entering a title and adding a layout table to a form produces a base form.
Add Controls
Scenario/Problem:
You need to add controls to a form for user entry.
Solution: Use the Controls section from the Home top ribbon bar.
To add controls to your form, follow these steps:
1.
Click the first Add Control cell in the layout table of the form.
2.
From the Home ribbon bar, locate the Controls section, as shown in Figure 2.3, and click Text Box.
FIGURE 2.3. The Controls section displays the available controls that you can insert onto your form.
3.
4.
Click the Add label in the cell to the left of the text box and enter a label for this entry. This tells the
user what information to enter into the text box.
Repeat these steps for the remaining rows in the layout table. Your form should look similar to Figure
2.4.
FIGURE 2.4. Adding labels and controls to the form provides the basis for user data entry.
5.
Click Save from the File menu to save your changes locally.
You need to see how your form works before you publish it to SharePoint.
Solution: With your form open and saved, there are three ways to preview the contents:
Click the magnifying glass icon at the very top of the InfoPath Designer application.
Your form will render in the InfoPath Filler version of the application, and you can view how it works there, as
shown in Figure 2.5.
FIGURE 2.5. Previewing your form shows you how the user will experience it.
FIGURE 2.6. Naming your fields appropriately makes them easier to identify and manage.
NOTE
To be consistent, naming conventions should be established. Developers may use camel case (for example, lastName,
firstName), whereas business analysts might use Pascal case (for example, LastName, FirstName). There is no wrong or
right answer as long as everyone follows the same standards.
Solution: From the File menu, select Info. On the Info page, click the Submit Form button.
Several options appear (as shown in Figure 2.7):
To Email: Submitting this form sends the contents in an email to a specified address.
To SharePoint Library: Submitting this form sends the contents as a saved instance of the form in a
SharePoint form library.
To Web Service: Submitting this form sends the form as XML to a web service.
To SharePoint Server Connection: Submitting this form uses a specified data connection stored in
SharePoint to submit the data.
Submit Options: If you are familiar with InfoPath 2010 or just want to take control of the submit
options, use this item menu to just get down to business.
FIGURE 2.7. Submit options determine where and how a completed form will be submitted.
For this scenario, select To SharePoint Library. The Data Connection Wizard appears. For the form to be
submitted to that form library, you need to have a data connection to the SharePoint library in the form.
You must specify a form library in SharePoint to submit the form; therefore, you might need to go to your
SharePoint site and create a new form library first. Enter the location of the form library in the Document Library
text entry. (Create a form library named SharePoint Forms for this example.)
TIP
You can create the form library right from InfoPath, as explained in a later section.
Now that some of the grunt work has been done, we come to the most important part of the submission to a
document library: the filename. If you notice, by default, the filename is Form. Thats great. If you leave it like
that, only one person can submit the form, it will be called Form.xsn in the form library, and no one ever can
submit the form again. Lets go home!
You need to specify something dynamic or unique about the form instance the user is submitting. This can be
tricky. You must define a formula to implement this correctly, and although we havent stepped through formulas
yet, we are forced to do at least one here.
The main ingredients for specifying the filename correctly deal with either entries in the form or entries in the
form combined with a system function such as the date.
For this example, we use the name the user entered in the form along with a date function. To do so, follow
these steps:
1.
Click the Function button to the right of the File Name text box. The Insert Formula dialog appears.
2.
Click the Insert Function button and select the concat function. Click OK. The function inserts three
spots for you to modify.
3.
Double-click the first entry and select the Name field from the field dialog that appears and click OK.
4.
Only select the next entry (dont double-click) and replace it with , including the quotation marks.
5.
Select the last entry and click the Insert Function button. Select Today from the Date category.
6.
Click OK.
7.
Remove the Double-Click to Insert Field text if it still appears. Click OK. Your formula should now look
similar to Figure 2.8.
FIGURE 2.8. Using a formula for the filename ensures that each instance is saved to a unique file.
8.
Click Next. If you are prompted for credentials, enter them accordingly.
9.
TIP
If you use the now date function, the time component will be used in the filename, and even if you select to
overwrite existing files, the filename will never be the same (because the time changes every second). Avoid
this, if possible, because every update generates a new file.
3.
4.
5.
6.
Select the existing form library from the list, as shown in Figure 2.12. (To create a new form library see
the Create a Form Library from InfoPath section later in this chapter.)
Click Next. Click Next. Click Publish. The form is published to your SharePoint form library.
FIGURE 2.12. Select Update the Form Template in an Existing Form Library.
TIP
After you have stepped through the publish process once, you can facilitate future republishing of your form by
using the Quick Publish button.
FIGURE 2.13. Clicking the Add Document link opens a new instance of your form within the browser.
FIGURE 2.14. Submitting the form saves an instance of the form within the form library.
NOTE
When you use certain SharePoint site templates, such as the Blank Site template, the Enterprise features
might not be enabled. You need to make sure that Enterprise features are enabled to publish the form as a
browser-enabled form.
NOTE
The Save and Save As buttons shown here allow the user to save the form using a filename. This circumvents
the configured Submit button. Chapter 8, Submitting and Publishing in SharePoint, discusses how to change
the buttons that appear.
In the preceding section, you created the form library manually. By doing so, you understood where the
InfoPath form was going to be published and submitted. When starting from scratch with the Blank Form
template, you can use the Publish Form to a SharePoint Library option to create the form library and publish
the form, but you also need to enter submit options after the form has been published. Therefore, you need to
publish again after you have entered the submit options. It becomes a chicken-or-the-egg scenario.
Nonetheless, if you create a form using the Blank Form template, you may create the form library to house it
using the Publish Form to a SharePoint Library option, as follows:
1.
From the File menu, select Publish. On the Publish page, click SharePoint Server (Publish Form to a
SharePoint Library). The Publishing Wizard appears.
2.
Enter your main SharePoint URL or the full site address where you want the form library created and
click Next.
3.
Keep the defaults to create a form library and use the form in the web browser. Click Next.
4.
Select the Create a New Form Library option, as shown in Figure 2.15, and click Next.
FIGURE 2.15. Selecting the Create a New Form Library option allows you to create the form library from
InfoPath.
5.
Enter the name of the new form library and a description on the next wizard dialog and click Next.
6.
7.
FIGURE 2.16. The SharePoint Form Library template provides more starting material for when youre designing
a new form.
TIP
The SharePoint Form Library template is a glorified version of the Blank Form template.
So, now you can use this template and apply the same techniques described earlier in this chapter to publish
the form to SharePoint. However, you still need to create a form library and configure the submit options.