InfoPath Forms with Master Page Applied or Script Enabled


  • Previously posted in the Office365 forums.

    I'm trying to do something seemingly simple, but lo, it is not.

    I have an InfoPath form that works great. One of the things I need to work in it is a little bit of script which is similar to the one in my blog post called Using SPServices with jQueryUI’s Autocomplete Function on InfoPath Forms in SharePoint. The basic idea is to add some autocomplete functionality to a field on the form, choosing (in this case) from a list containing 19000 cities and towns.

    To implement the script in the form, I've created a new aspx page and dropped an InfoPath Form Web Part on it to display the form. By adding a few well-placed links to that page on the site, it's easy to get there to create a new InfoPath item.

    The problem comes in when we want to edit an existing form. Because links to the form go to /sites/Projects/_layouts/15/FormServer.aspx?XmlLocation=..., I can't get my script to run in the page. The FormServer.aspx page doesn't pick up the chrome or anything else from my master page, where I've put the script references.

    I feel like I'm getting close with the script below based on the suggestion here

    //Rewrite Form Links to Open in Custom Page
    $("[href*='/sites/Projects/Sales Orders']").each(function() {
        var formFileName = $(this).attr("href");
        var formServerUrl = "/sites/Projects/SitePages/Manage%20Sales%20Orders.aspx";
        $(this).bind("click", function(e) {
            var destination = formServerUrl + "?XmlLocation=" + formFileName + "&Source=" + location.href;
            location.href = destination;
    The script works, in that it rewires all of the existing links to the FormsServer.aspx page correctly, sending me to a link that looks something like this, which is basically what I want:

    Unfortunately, the InfoPath Web Part then shows the error below. There has to be some way to pass the XmlLocation to the InfoPath Web Part successfully.

    There has been an error while loading the form.
    Click Try again to attempt to load the form again. If this error persists, contact the support team for the Web site.

    Click Close to exit this message.
    Hide error details
    XmlLocation and XsnLocation have both been set to non-empty values. It is an error to set both to non-empty values. Set XsnLocation to open a new copy of the form template. Set XmlLocation to open the xml file corresponding to an existing InfoPath document.

    So the bottom line question is either:

    • How can I get the master page to apply to the Formserver.aspx page (I'm thinking this isn't possible), or
    • How can I get the links to the existing forms to go to my custom aspx page?

    Thanks in advance for any useful ideas. This doesn't seem like such a strange thing to want to do, if only to maintain the chrome and look and feel.

    p.s. Formatting this post in Internet Explorer 11 simply doesn't work. Yet again, I had to switch to Firefox to get something done. Erg.

    Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services (SPServices)

    Saturday, January 11, 2014 11:07 PM