Open Form in Modal Dialog - InfoPath Dev
in

InfoPath Dev

Open Form in Modal Dialog

Last post 11-04-2011 03:40 PM by canadiense. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-02-2011 08:06 AM

    Open Form in Modal Dialog

    I have created an Infopath 2010 web form for use on a Sharepoint 2010 site.This form does not submit to a list or library, but submits data directly to SAP via web services.

    My sharepoint page was created in SharePoint Designer 2010, so I'm restricted to XSL and javascript. it has a dataview web part with a connection to web services that retrieves a list of items from SAP. In the XSL I am building a link to the IP form on each item in the list, passing in querystring parameters so that the form can run queries and prepopulate the form from web services. The link is to a Javascript function that executes the SP.UI.ModalDialog.showModalDialog function. This is done in an attempt to make the form look and act like standard Sharpoint list and library forms, and grays out the background page until the modal dialog box is closed.

    All is working well with one exception: when I close the form (with an infpath button using the close form rule) I get the familiar ' The form has been closed' message in the modal dialog box. I then have to click the X button in the modal dialog to return to the page I was on. I would like for the modal dialog box to close when the Infopath form button is clicked, but I can't figure out how to do it. I tried adding the SP.UI.ModalDialog.close command to the callback function, but it doesn't get executed until the dialog is actually closed. Does anyone have any insight on how to do this?

    Here is my javascript and XSL code:


    function openForm(formurl, title, w, h) {
    var options = {
     url: formurl,
     title: title,
     allowMaximize: false,
     showClose: true,
     width: w,
     height: h,
     dialogReturnValueCallback: Function.createDelegate(null, FormCallback)
     };
     
     SP.UI.ModalDialog.showModalDialog(options);
    }

    function FormCallback(dialogResult, returnValue) {
     SP.UI.Status.removeAllStatus();
        havascript:location.reload(true);
    }
    </script>

    Then in the XSL of the web part, I add a column at the beginning of the row: 

        <xsl:if test="Status='Draft'">
         <a style="font-size:8pt; font-weight:bold;" title="Edit" href="havascript:void(0);">
          <xsl:attribute name="onclick">
           <xsl:value-of select="concat('openForm(&quot;http://webapp/sites/thesite/formservertemplates/Request.xsn?RequestID=',RequestID ,'&amp;Operation=edit&amp;OpenIn=Browser&quot;, &quot;Request&quot;, 1125, 800)')" />
          </xsl:attribute>
                      <img style="border:none;" src="../PublishingImages/EditReq.gif" />
         </a>
        </xsl:if>

    NOTE: I have changed the word javascript to havascript in the code so it will render properly.

    Steve
  • 11-04-2011 03:40 PM In reply to

    Re: Open Form in Modal Dialog

    Steve - did you ever find an answer to your question?  Enquiring minds want to know! :)
    Chris ... er, Arthur Fonzarelli!
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.