Opening an Infopath form library template from Infopath in a link

I've found a lot of bad info on how to do this and it's not well documented so hopefully this helps someone:

first create a JavaScript function so that your links aren't super long:


<script type="text/javascript">
            function OpenForm(absSiteUrl, siteRelFormUrl, siteRelSaveUrl)
            {
                        var formUrl = absSiteUrl + siteRelFormUrl;
                        var saveUrl = absSiteUrl + siteRelSaveUrl;
                        var formSvcUrl = absSiteUrl + "_layouts/FormServer.aspx?XsnLocation=" + formUrl;
                        CoreInvoke('createNewDocumentWithRedirect2',event, formUrl, saveUrl, 'SharePoint.OpenXmlDocuments.2', true, formSvcUrl, false, 0);
            }
  </script>

then create a link like so:

<a href="javascript:OpenForm('[AbsoluteSiteUrl]','[SiteRelativeFormUrl]','[SiteRelativeSaveLocationUrl]')">open form</a>

here are examples for the vars
[AbsoluteSiteUrl] = http://mysp2010server/siteA/
[SiteRelativeFormUrl] = myformlibrary/Forms/template.xsn
[SiteRelativeSaveLocationUrl] = myformlibrary

Comments

Popular posts from this blog

Programmatically Update Page Layouts

Microsoft Virtualilzation Headaches

ERROR: Failed to create feature receiver...