Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form - InfoPath Dev
in

InfoPath Dev

Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

Last post 01-06-2011 11:23 PM by MingleLui. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-25-2009 06:43 AM

    Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    Hello,

    I am developing a web-based form with InfoPath 2007 that is hosted in MOSS (InfoPath Forms Services, FormServer.aspx)

    The form is used in a workflow provided by a 3rd party product that integrates with MOSS and InfoPath.

    Rather than using the toolbar with the "Send" button provided by InfoPath, the form uses buttons inside it, with actions such as "Submit", "Accept", "Reject", "Return to sender", etc. depending on the view used by the workflow.

    The fields of the form have complex business validations that require code to perform them. Some of them must be performed before the form is submitted (not tied to the Changed or Validating events of fields).

    After performing those validations, if they pass, the form must be submitted and closed (redirecting to previous web page or to a custom one). I have everything done except the part of closing the form:

    The buttons have the action "Rules and custom code" and in the custom code I perform the validations and if successful I execute a connection to submit the form. At that point, I would like to close the form programmatically but it seems (searching the web) that there is no way to close programmatically a web-based form handled by FormServer.aspx. I have tried adding a reference to System.Web and getting the HttpContext and then all kinds of tricks such as HttpContext.Response.Redirect or HttpContext.Server.Transfer. All of them either are ignored or cause an error (InfoPath Form Service shows an error).

    It seems that the only way to close a web-based form is to set the button action to "Submit", and in the Submit Options:

    - Set the Custom Code radiobutton

    - In the Advanced section, set the value "Close the form" in the combobox.

    But using the custom code radiobutton I get the same FormEvents_Submit event handler for all the buttons, and it seems that there is no way to get the button that was clicked, so I can't do different things depending on the button that was clicked.

    So, is there a way in web-based forms of

    a) having different submit buttons with custom code

    b) that perform different validations (depending on the button clicked) before actually submitting the form through a connection and

    c) then closing it (or redirecting it to some custom web page)?

    Thanks in advance,

    Carlos Quintero

    Visual Basic MVP

     

     

     

  • 11-29-2009 08:52 PM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    Hi Carlos,

    Thanks for the detailed question. Sorry for the delay in responding.

    You can use xdExpression to call out to code that validates via a rules condition section and use actions to Submit and Close the form if that succeeds. That would be one way to use a custom rule on a button with code to validate, submit and close the form.

    Hope that helps!

    Patrick Halstead
    Project Manager at Qdabra
  • 11-30-2009 04:27 AM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    Hello Patrick,

    Thanks for answering. Can you clarify how to use "xdExpression"? I search on Google gives 4 results, all in this site, and 3 of them says to do a search in this forum but no one actually explains what xdExpression is or how to use it. I am using InfoPath 2007 and web-based forms (InfoPath Form Services).

    Thanks in advance,

     

    Carlos

  • 11-30-2009 05:12 AM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    Patrick Halstead
    Project Manager at Qdabra
  • 11-30-2009 09:05 AM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    Hello Carlos,

    I have done something similar in my own projects --- I always use a popup window to show the infopath form in a browser window --- and after submit I always want to close the form automatically...

    What I have done is the following:

    1. Put a file called "WindowClose.htm" in a folder under "_layouts/YourApplicationFolder/"

    The content of the file is:

    <html>
    <head>
    <script type="text/javascript" language="JavaScript">
     self.close();
    </script>
    </head>
    </html>

    2. In the submit code (I always use my own submit code) you can code:

    // Use the pre-defined Submit-Connection
    FileSubmitConnection fc = (FileSubmitConnection)this.DataConnections["SPSubmitForm"];
    string Location = this.CurrentSiteUrl.ToString();
    string Uri = this.CurrentDocLib.ToString();
    string Path = Uri.Substring(0, Uri.LastIndexOf("/"));
    string Folder = Path.Substring(Path.LastIndexOf("/") + 1);
    string closeWindowPath = "/_layouts/YourApplicationFolder/windowclose.htm";

    // Exceute Submit
    fc.FolderUrl = Location + "/" + Folder;
    fc.Execute();

    // Redirect/Close des Formulars
    HttpContext.Current.Response.Redirect(string.Concat(Location, closeWindowPath), false);

    Now after submit the form window will be closed...

    Hope that helps,

    Karsten
    Filed under:
  • 04-21-2010 02:29 PM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    I having trouble redirecting from my submit functions:

    System.Web.HttpContext.Current.Response.Redirect("http://portal",false);

    as an ironic twist it actually opened the debugger in the browser but gives me some kind of Javascript Error.

  • 01-06-2011 11:23 PM In reply to

    Re: Close a web-based (MOSS) InfoPath 2007 form when using multiple (different) buttons to submit the form

    I use the same method,but I got js error too.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.