DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 826993 - Last Review: August 13, 2010 - Revision: 1.0

On This Page

INTRODUCTION

In the original release of Microsoft Office InfoPath 2003, you cannot submit form data to a Microsoft Windows SharePoint Services document library directly. This article describes how to design a form template that uses script to submit form data to a Windows SharePoint Services document library. In InfoPath 2003, Service Pack 1 (SP1) and later versions of InfoPath, you can submit the form data to a Windows SharePoint Services document library directly by using the UI. This article contains the steps that you have to use to do this.

MORE INFORMATION

Design your form data source and layout in InfoPath 2003

  1. Start InfoPath. Design a new blank form.
  2. In the Data Source task pane, add a data source to your form. To do this, follow these steps:
    1. Right-click myFields, and then click Add.

      The Add Field or Group dialog box appears.
    2. Type FirstName as the name of the field, and then click OK.
    3. Repeat step a. Type MiddleInitial as the name of the field, and then click OK.
    4. Repeat step a. Type LastName as the name of the field, and then click OK.
  3. Add myFields to your form.
  4. Click Section with Controls.

Design your form data source and layout in InfoPath 2007

  1. Start InfoPath 2007.
  2. Click Design a Form Template, click Blank, and then click OK.
  3. In the Design Tasks pane, click Data Source.
  4. Right-click myFields, and then click Add.
  5. In the Add Field or Group window, type FirstName as the name of the field, and then click OK.
  6. In the Add Field or Group window, type MiddleInitial as the name of the field, and then click OK.
  7. In the Add Field or Group window, type LastName as the name of the field, and then click OK.
  8. Add the myFields group to the form, and then click Controls in Layout Table.

Design your form data source and layout in InfoPath 2010

  1. Start InfoPath 2010.
  2. In Popular Form Templates, click Blank, and then click Design this Form.
  3. If there is not a Design Tasks pane, click Data Source.
  4. If there is not a Fields pane displayed to the right, then on the Data tab, click Show Fields.
  5. In the Add Field or Group window, type FirstName as the name of the field, and then click OK.
  6. Add another field. In the Add Field or Group window, type MiddleInitial as the name of the field, and then click OK.
  7. Add another field. In the Add Field or Group window, type LastName as the name of the field, and then click OK.
  8. Add the myFields group to the form.

Submit the form data to a SharePoint Services document library

You can use script or the UI to submit the form data to the SharePoint Services document library.

Use script to submit the form data to a SharePoint Services document library in InfoPath 2003

  1. On the Tools menu, click Submitting Forms.

    The Submitting Forms dialog box appears.
  2. In the Submitting Forms dialog box, click Enable Submit.
  3. In the Submit box, click Submit Using Custom Script.
  4. Click Open Microsoft Script Editor, and then click OK.

    Microsoft Script Editor starts.
  5. Modify the OnSubmitRequest event as follows.

    Note You must change the value of the strURL variable to a valid URL in the code. The URL in the following code sample references a server that is named ServerName, a SharePoint site that is named SiteName, and a document library that is named DocumentLibraryName.
    function XDocument::OnSubmitRequest(eventObj)
    {
        // If the submit operation is successful, set
        // eventObj.ReturnStatus = true.
        var fSuccessful = false;
     
        // Set the URL of the file that you want to submit here.
        var strUrl = "http://ServerName/SiteName/DocumentLibraryName/testform.xml";
     
        try 
        { 
            // Create an xmlhttp object.
            var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
     
            // See whether the document with the same name already exists in the Windows SharePoint Services (WSS) document library.
            oXmlHttp.Open("HEAD", strUrl, false); 
            oXmlHttp.Send(); 
     
            //  No document with the URL has been found. Continue to submit.
            // If you must replace the original file, you must call
            // oXmlHttp.Open("DELETE", strUrl, false) to delete the document 
            // in the WSS document library.
            if (oXmlHttp.Status == 404) 
            {
                // Put the document in the WSS document library. 
                oXmlHttp.Open("PUT", strUrl, false); 
                oXmlHttp.Send(XDocument.DOM.xml);
     
                //  A 200 status code or a 201 status code indicates that the form has been submitted successfully.
                if (oXmlHttp.Status == 200 || oXmlHttp.Status == 201)
                {
                    fSuccessful = true;
                }
            }
        } 
        catch (ex){} 
        
        if (fSuccessful)
        {
            XDocument.UI.Alert("Document submitted successfully."); 
            eventObj.ReturnStatus = true;
        }
        else
        {
            eventObj.ReturnStatus = false;
        }
    }
    
  6. Save the script. Close Script Editor.
  7. Save your form template as SubmitToWSS.xsn.

Use the UI to submit the form data to a SharePoint Services document library in InfoPath 2003 Service Pack 1

  1. On the Tools menu, click Submitting Forms.

    The Submitting Forms dialog box appears.
  2. In the Submitting Forms dialog box, click Enable Submit commands and buttons.
  3. In the Submit to section, click SharePoint form library.
  4. In the Submitting Forms dialog box, click Add.

    The Data Connection Wizard starts.
  5. Input your SharePoint Services form library link in the SharePoint form library box.

    Your library link may look similar to the following:

    http://ServerName/SiteName/DocumentLibraryName
  6. Type the document name in the File name box.

    You can use a document name such as TestForm.

    Click Next.
  7. In the Data Connection Wizard, click Finish.
  8. In the Submitting Forms dialog box, Click OK.
  9. Save your form template as "SubmitToWSS.xsn."

Use the UI to submit the form data to a SharePoint Services document library in InfoPath 2007

  1. On the Tools menu, click Submit Options.

    The Submit Options dialog box appears.
  2. In the Submit Options dialog box, click Allow users to submit this form.
  3. Click to select the Send form data to a single destination check box.
  4. In the drop-down list, click SharePoint Document Library.
  5. In the Submit Options dialog box, click Add.

    The Data Connection Wizard starts.
  6. Type your SharePoint document library link in the Document Library box.

    Your document library link may resemble the following:
    http://ServerName/SiteName/DocumentLibraryName
  7. Type the document name in the File name box.

    You can use a document name such as TestForm.
  8. Click Next.
  9. In the Enter a name for this data connection box, type a name for this data connection.
  10. In the Data Connection Wizard, click Finish.
  11. In the Submit Options dialog box, click OK.
  12. Save your form template as SubmitToWSS2007.xsn.

Use the UI to submit the form data to a SharePoint Services document library in InfoPath 2010

  1. On the Data tab, click Submit Options.

    The Submit Options dialog box appears.
  2. In the Submit Options dialog box, click Allow users to submit this form.
  3. Click to select the Send form data to a single destination check box.
  4. In the drop-down list, click SharePoint Document Library.
  5. In the Submit Options dialog box, click Add.

    The Data Connection Wizard starts.
  6. Type your SharePoint document library link in the Document Library box.

    Your document library link may resemble the following:
    http://ServerName/SiteName/DocumentLibraryName
  7. Type the document name in the File name box.

    You can use a document name such as TestForm.
  8. Click Next.
  9. In the Enter a name for this data connection box, type a name for this data connection.
  10. In the Data Connection Wizard, click Finish.
  11. In the Submit Options dialog box, click OK.
  12. Save your form template as SubmitToWSS2010.xsn.

Test your form in InfoPath 2003

  1. On the File menu, click Fill Out a Form.
  2. In the Fill Out a Form task pane, click SubmitToWSS.
  3. Complete the form.
  4. On the File menu, click Submit.

    If the form is submitted successfully, you receive a message that indicates this.
  5. Quit InfoPath. If you are prompted to save your changes to the form, click No.
  6. Start Microsoft Internet Explorer. Locate your document form library.

    For example, your document form library may be http://ServerName/SiteName/DocumentLibraryName.

    A new item that is named testform is in the document library.
  7. Click testform.

    The form that you submitted opens in InfoPath 2003.

Test your form in InfoPath 2007

  1. On the File menu, click Fill Out a Form.
  2. In the Fill Out a Form task pane, click SubmitToWSS2007.
  3. Complete the form.
  4. On the File menu, click Submit.

    If the form is submitted successfully, you receive a message that indicates this.
  5. Quit InfoPath. If you are prompted to save your changes to the form, click No.
  6. Start Windows Internet Explorer. Locate your document form library.

    For example, your document form library may be http://ServerName/SiteName/DocumentLibraryName.

    A new item that is named testform is in the document library.
  7. Click testform.

    The form that you submitted opens in InfoPath 2007.

Test your form in InfoPath 2010

  1. Start InfoPath Filler 2010
  2. Click Find a Form.
  3. Find SubmitToWSS2010.xsn, select it, and then click Open.
  4. Complete the form.
  5. On the File menu, click Submit.

    If the form is submitted successfully, you receive a message that indicates this.
  6. Quit InfoPath Filler. If you are prompted to save your changes to the form, click Don't Save.
  7. Start Windows Internet Explorer. Locate the document library that you provided in step 6 of "Use the UI to submit the form data to a SharePoint Services document library in InfoPath 2010."

    You will see a new Form item in the document library, and your name will appear in the Modified By column.
  8. Click the new Form item.

    The form that you submitted opens in InfoPath 2010.

REFERENCES

For more information about how to obtain the latest service pack for Microsoft Office, click the following article number to view the article in the Microsoft Knowledge Base:
870924  (http://support.microsoft.com/kb/870924/ ) How to obtain the latest service pack for Office 2003
For more information about how to script with InfoPath 2003 forms, click the following article numbers to view the articles in the Microsoft Knowledge Base:
828853  (http://support.microsoft.com/kb/828853/ ) How to change the script language for your InfoPath form
827002  (http://support.microsoft.com/kb/827002/ ) How to debug a script for a Microsoft Office InfoPath 2003 Form

APPLIES TO
  • Microsoft Office InfoPath 2007
  • Microsoft Office InfoPath 2003
  • Microsoft Windows SharePoint Services 2.0
  • Microsoft Infopath 2010
Keywords: 
kbhowto kbxml kbscript kbforms KB826993
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support