Creating Installable InfoPath form Template and deploying in SharePoint


In this article I will explain how can we create and publish browser enabled InfoPath form in SharePoint site.

Steps Involve

1. Step 1: Design info path form
2. Step 2: Creating Installable InfoPath form Template
3. Step 3: Deploying form in SharePoint


Step 1: (Design Info Path Form)

To design InfoPath form please refer to my previous article "Creating browser enabled InfoPath forms for SharePoint library"

After designing form Right click on button control (which you have added in your form) and select button properties.

image1.gif

Select Submit from the "Action" dropdown and Change the label of button and click on "Submit Option" button. Click on "Submit Option" button.

image2.gif

From submit options popup, Click on "Allow users to submit this form "check box, select "Perform custom action using Code" and click on "Edit Code…" button.

image3.gif

Now Visual Studio project will be open where you can write your code to submit data into SharePoint library.

Steps to select your programming language and project location(Before clicking on Edit Code
button)

  1. Go to "Form Options" from the Tools menu.
  2. Click on "Programming" tab. Here you select From template code language and you can browse
    code location as well.

    image4.gif

Add SharePoint reference in your SharePoint solution.

using Microsoft.SharePoint;

Write following code to "FormEvents_submit" event.

public void FormEvents_Submit(object sender, SubmitEventArgs e)

        {

            XPathNavigator root = this.MainDataSource.CreateNavigator(); 

            SPSecurity.RunWithElevatedPrivileges(delegate()

            {

                using (SPSite site = new SPSite("http://maaasdw002:3304"))

                {

                    using (SPWeb web = site.OpenWeb())

                    {

                        SPList list = web.Lists["CustInfo"];

                        SPListItem newItem = list.Items.Add();

                        newItem["Title"] = root.SelectSingleNode("/my:myFields/my:custTitle", this.NamespaceManager).Value;

                        newItem["CustName"] = root.SelectSingleNode("/my:myFields/my:custName", this.NamespaceManager).Value;

                        newItem["Age"] = root.SelectSingleNode("/my:myFields/my:Age", this.NamespaceManager).Value;

                        newItem["Address"] = root.SelectSingleNode("//my:myFields/my:Address", this.NamespaceManager).Value;

                        newItem.Update();

                    }

                }

            });

            e.CancelableArgs.Cancel = false;

            // Write your code here.
        }

        In the above code XPathNavigator is an object to navigate InfoPath

Step 2: (Creating Installable InfoPath Form Template)

From the design task pane click on "Publish Form Template". From publishing wizard select first option to publish form in share point and click on next button.
 

image5.gif

Enter the URL of SharePoint site and click on next button.

image6.gif

From the next window select "Administrator-approved form template" and click on next button and click on Publish button to publish form.

image7.gif

Specify a location and file name for the form template and click on next - next button and click on Publish button to publish the form.
 

image8.gif
image9.gif

Step 3: (Deploying InfoPath form in SharePoint)

Open Central Administrator go to "Application Management" and click on "Upload Form template" from InfoPath Forms Services section
 

image10.gif

A new window will be open to upload form template. Browse the template location and click on upload button to upload form template.
 

image11.gif


Now go to your SharePoint site settings and select "Site collection features".
 

image12.gif

Search your form template and click on Activate button to activate the form.
 

image13.gif

After activating form template go back to site settings page and select "Site Libraries and lists" from the Site libraries and lists.
 

image14.gif

Select Form Templates Library and go to the form template library and click on your template.
 

image15.gif

A new form will be open in the browser( to open form in the browser go to Document Library settings>>Advance settings and select "display as a web page")

Fill the form and click on save data button to save data in the list.
 

image16.gif

Open "CustInfo" list to view your data.
 

image17.gif

In my next article I will explain how can How can we open info path forms inside the SharePoint web page.

Thanks for reading...
  

Up Next
    Ebook Download
    View all
    Learn
    View all