Launch WSS forms library InfoPath form from a web page

Applies to: InfoPath 2003

Use javascript within a web page to mimic the behaviour of Fill Out This Form in a WSS Forms Library and be able to launch an InfoPath form from a web page.

ADVERTISEMENTS

Problem

You have a form that was published to a Windows SharePoint Services (WSS) site's forms library and would like to be able to launch InfoPath to fill out the form by clicking on a hyperlink on a web page.

Solution

Mimic the behavior of Fill Out This Form in a SharePoint Forms Library by reusing the javascript functions that provide this behavior from SharePoint's ows.js file.

Discussion

You can accomplish this functionality as follows:

  1. Copy and paste the following code in the <HEAD> of your web page:
    <script language="javascript" src="owsfunctions.js"></script>
    <script language="javascript">
    var strTemplate = "http://<SERVER>/sites/<WSS_SITE>/<WSS_FORMS_LIB>/Forms/template.xsn";
    var strSaveLocation = "/sites/<WSS_SITE>/<WSS_FORMS_LIB>";
    var strProgID = "SharePoint.OpenXMLDocuments";
    function fillOutForm()
    {
    createNewDocumentWithProgID(escapeProperlyCore(strTemplate, true), makeAbsUrl(strSaveLocation), strProgID, true);
    }
    </script>
    Change "http://<SERVER>/sites/<WSS_SITE>/<WSS_FORMS_LIB>/Forms/template.xsn" to point to the correct InfoPath form template and "/sites/<WSS_SITE>/<WSS_FORMS_LIB>" to the location where filled out InfoPath forms should be stored.
  2. Add a hyperlink to the <BODY> of your web page:
    <a href="javascript:fillOutForm();">Open InfoPath form</a>

You should now have a link on your web page that when clicked on will open the InfoPath form template that was published to your Windows SharePoint Services site's forms library to be filled out and saved back into the WSS forms library.

NOTE: If the location of the forms library specified in your web page differs from the location of the forms library specified in the form, then the form will be submitted to the location indicated within the form and not to the one specified in your web page.

 


Related InfoPath Articles:

 

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services