Creating web enabled InfoPath forms
 
In this article, we will learn how to create web enabled InfoPath forms. InfoPath is an information gathering tool and is used to create XML forms. People have always been trying to come up with a standard for creating electronic forms. Before InfoPath, companies created electronic forms in different formats. InfoPath has helped companies to adhere to a standard. Coding XML manually may not be an interesting job but creating XML forms with InfoPath has really made this job quite easier.

All clients must have InfoPath installed on their machines in order to open the forms. It could be a problem for smaller companies to provide InfoPath client to all the users. What can be the solution then? Solution is to create web enabled forms that can be opened in web browser without having to install InfoPath client on user machines.

Following is a step-by-step guide that will show you how to create and deploy a web enabled form:

1. Open InfoPath (Start > All Programs > Microsoft Office > Microsoft Office InfoPath 2007)

2. On the "Getting Started" screen, under "Design a form", click "Design a form template".

3. On the "Design a form template" screen, select "Form Template" and check the checkbox "Enable browser-compatible features only" at the bottom. Make sure it's based on a "Blank" template.

Design a form template

4. From the "Format" menu, select "Layout...".

Layouts menu

5. From the "Layout" table on the right side, select "Table with Title". This will insert a table with a header. You can change the color theme by selecting a color scheme from the "Format > Color Schemes..." menu.

6. Change the header to "User Registration".

7. Click in the area "Click to add form content". Right-click the area and select "Split Cells..." from the menu. Split the column into two. Add following labels in the left column. Add each label in a new row:

- First Name
- Last Name
- Address
- Zip
- City
- State
- Country
- Phone
- Fax
- Web

8. In the right column, add text boxes against each label. Click "Design Tasks" from the table on the right side.

Design Tasks

9. Click "Controls" in the design tasks and then select "Text Box" from the "Standard" controls section. Drag text box into the first row, second column and rename it to "FirstName". To rename, right click the text box and select "Text Box Properties" and change the field name. Do the same for all other fields, add text boxes and rename them as following:

- LastName
- Address
- Zip
- City
- State
- Country
- Phone
- Fax
- Web

Tip: Use font "Verdana" and size "8.5".

10. Add two buttons at the bottom and rename them to "Submit" and "Close". The completed form will look like the following:

User Registration Form

11. From "Tools" menu, select "Form Options..."

Form Options

12. Make sure "Browser" is selected in the "Category" and uncheck the following toolbar options:

- Show toolbar at top of form
- Show toolbar at bottom of form

13. Select "Security and Trust" in "Category". Uncheck "Automatically determine security level (recommended)" checkbox. Select "Full Trust (the form has access to files and settings on the computer)" option button.

14. Select "Programming" category. Select C# as the programming language and select a location to save the code.

Programming options

15. Select "Compatibility" category. Check the option "Design a form template that can be opened in a browser or InfoPath". Add  a URL in the text box provided below. This will be the URL of the forms services web service. The URL will be: http://server/_vti_bin/FormsServices.asmx

Note: server name in the URL above will be different for you.

Formservices

16. Click OK to save all these changes.

17. Ok, it's time to publish the form. Select "Publish..." from the "File" menu.

18. Select first option "To a SharePoint server with or without InfoPath Forms Services" in the publishing wizard.

19. Provide a URL where this form will be published. This will be location on your SharePoint server. You can select the root  path, for example, http://server and click "Next".

20. Check the option "Enable the form to be filled out by using a browser" and click "Next".

21. Click "Browse" button and select a location on your hard disk where this template will be saved. Give your template a name. I named it "userregistrationtpl.xsn". Click "Next".

22. Click "Add" button to add columns that you want to appear on your SharePoint Forms Library.  For example, Click "Add" and then select "FirstName" from the columns. Select "(None: Create new column in this library)" option from the "Site column group:" drop down. A column name "First Name" will automatically be entered in the "Column name". You can change it to your liking. Add as many columns as you like and click "OK" to save.  Click "Next" then click "Publish" and finally click "Close" to close the wizard.

Add Columns

Uploading the published web form

23. There are two ways to upload the published web form to SharePoint: Using the interface provided by SharePoint and using the command line tool stsadm.exe. I will show you both methods. First, let's try the first method, that is, using the SharePoint admin interface. Open "SharePoint Central Administration" site by selecting Start > All Programs > Microsoft Office Server > SharePoint 3.0 Central Administration.

central admin site

24. Select "Application Management" from "Central Administration". In "InfoPath Forms Services" section, select "Manage form templates". If you don't see this seciton, probably you might not have configured the forms services on your server. Enable "Forms Services" on your server. The following technet article has the details:

http://technet.microsoft.com/en-us/library/cc262263.aspx

25. Click on "Upload form template". Browse to the folder where you saved the template and select the template file. Click the "Verify" button to make sure there are no errors in your template. This is not required in this template because this is a very small template without any code but you should always verify the template before uploading if it has code and has a complicated layout. Leave the default options as they are and click "Upload".

upload template

26. You will see a message after the form has been uploaded. Click Ok. You will be shown the list of uploaded forms. Select the form you just uploaded. Move the mouse over the form name. Click the down arrow. Select "Activate to a Site Collection".

activate form

27. Change the site collection in the "Site Collection" drop down. If you only have one site collection then you don't need to worry about it. If you have multiple site collections, then select the one where you want to activate the template. Click the down arrow and then click "Change Site Collection". Change the web application in the "Web Application" drop down. Again if you have only one web application or the web application of your choice is already selected then leave it as it is. You can select a site from the left side that shows the sites' links. By default, root "/" is selected. Click OK. Click OK again to activate the template on the site collection you selected.

site links

Preparing the Forms Library


28. Open a SharePoint site. If you have already created a Forms library then you just need to configure it for the InfoPath template otherwise, create a new Forms Library. Open "Form Library Settings".

Settings

29. Go to "Advanced Settings". Set "Allow management of content types?" to "Yes". Set "Opening browser-enabled documents" to "Display as a Web page". In the "Folders" section, set "Display "New Folder" command on the New menu?" to "No". Set the last option "Allow items from this form library to appear in search results?" to "Yes". Click OK.

library settings

30. In the library settings' "Content Types" section, click "Add from existing site content types". Select the template that you uploaded from the list of available site content types and click the "Add >" button and click Ok.

add template
Remove the default content type "Form" from the content types. This is optional. Click the "Form" content type on the library settings page. From the "Settings", select "Delete this content type". Click OK to delete the content type.

delete content type

31. Go back to the library and click the "New" button. It will open the form template. That's it. You have just published a web enabled InfoPath form. The form doesn't do anything but the article was meant to show you the publishing process. In the next article we will make this form functional.

form
Download completed template