Launch WSS forms library InfoPath form from a web page
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.
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:
- Download owsfunctions.js
.
This is a stripped version of ows.js that provides functionality to open XML documents from SharePoint.
- Copy and paste the following code in the <HEAD> of your web page:
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.
<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> - 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:
