Close Infopath after submit does not work. - InfoPath Dev
in

InfoPath Dev

Close Infopath after submit does not work.

Last post 10-21-2009 05:13 AM by Svetoslav. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-30-2006 02:03 AM

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Close Infopath after submit does not work.

    I have seen many solutions on these forums to the problem of closing InfoPath after submit, but none of them seem to work for me.
    Of course, I tried using that code everyone provided here, but it just does not work. If I preview it in my own InfoPath, it closes just fine. However, when I or any other user fills it in from SharePoint it only closes the form and not the program.

    I am using the following code:
    function XDocument::OnSubmitRequest(eventObj)
    {
    Application.ActiveWindow.Close(true);
    }

    I am working with InfoPath 2003 sp2.

    Is it me? SharePoint? InfoPath? I see that piece of code everywhere so it must work for most, just not for us and it frustrates me.

    Thanks in advance.
  • 11-02-2006 07:32 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    Nobody ? I realise I am a newbie and to some of you this must be easy to solve, but I am going mad trying to figure out how to counter it. I am not experienced in either InfoPath or writing Jscript, but learning as I go along and trying to solve this has been a harsh tutor.

    I believe that the submit code of closing the form overrules my code of closing the program. I just do not know how to change it.
  • 11-02-2006 09:02 AM In reply to

    Re: Close Infopath after submit does not work.

    Hi Ilse and welcome to our forum,
    This code will close the window but not the InfoPath instance. To do that, you'll want the code that does an "Exit". Search for exit and tell me if you don't find something. We're here for you! :)
    Patrick Halstead
    Project Manager at Qdabra
  • 11-06-2006 08:02 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    Hi Patrick and thanks for responding.

    I have searched for "exit" and to my knowledge tried all kinds of variations to the theme. Like I said as far as I can see, my submit button code in closing the form overrules my exit codes. I am getting quite handy in making different kinds of forms, but the coding and Jscript part is just not my cup of tea. I am more of a software using type of girl, although I am learning simply by doing. Could you provide me with a simple script for me to build on?

    Thanks so much.
  • 11-06-2006 10:15 PM In reply to

    Re: Close Infopath after submit does not work.

    Hi,

    please try out this
    XDocument.View.Window.Close(true)
    Hope this will help you.
  • 11-07-2006 01:28 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    I presume you mean that I implement it into my existing code making it :

    function XDocument::OnSubmitRequest(eventObj)
    {
    XDocument.View.Window.Close(true);
    }

    And that does not work. It only closes the window, but thanks a lot. I appreciate all help I can get.
  • 11-15-2006 08:20 AM In reply to

    Re: Close Infopath after submit does not work.

    ilse:

    Here is the code I got from the good people on the Microsoft forum. Put this in in the code of a submit button. It first checks to be sure all required fields have values. It then attempts to submit.

    What I'm waiting for is a way to specify which data connection to submit to. Then, this code will be perfect for me. In the meantime, it does close InfoPath after submit.

    {
    if (XDocument.Errors.Count > 0)
    {XDocument.UI.Alert("Required information is missing as indicated by the red asterisk(s).") ;
    return;
    }
    try
    {
    XDocument.Submit()
    Application.ActiveWindow.Close(true);
    }
    catch(e)
    {
    XDocument.UI.Alert(e.description);
    }
  • 11-15-2006 08:30 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    Hi deb, I just read your whole post on the community about that and when I use that code it closed the program just fine, but I want it to submit something to my SharePoint too and it does not do that anymore. I need to write a custom submit code I presume, but I am not up to speed in doing that yet.

    I am actually having fun now trying to figure it out. If only I could combine the build-in submit to SharePoint and this closing code we'de be done.
  • 11-15-2006 08:35 AM In reply to

    Re: Close Infopath after submit does not work.

    That submits for me. I wonder if you have a number of data connections, which one it uses by default? I haven't attempted it in the current form I'm working on that has six (count 'em 6!) data connections. It's a workflow solution with multiple email submits.

    I hope someone here can help us with a solution. I guess 2007 will help with this, but our company is at least a year away from that. We're not early adopters.
  • 11-17-2006 01:24 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    No just 1 dataconnection. I made a new test form with only 1 button to just try and make this program close happen. If I just enable the sumbit to sharepoint via the submit button and add that code as OnSubmitRequest in Script editor it just leaves the form open but submits. If i change the submit to to custom submit with codes and add that code there, it closes just fine but does not submit. I presume I need to specify the whole submit routine. So I am searching for a custom submit code to SharePoint so I can add your code to it.
  • 11-17-2006 03:31 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    Succes !!! In my button I made a rule in my Rules and Custom code to use the main submit, edited the code like below and it works. I even got me a little success message. When I add a failure message the same way but with false it pops up right after the success one ( yes yes very funny :) )


    function CTRL1_5::OnClick(eventObj)
    {
    if (XDocument.Errors.Count > 0)
    {XDocument.UI.Alert("Required information is missing.")
    return;
    }
    if (eventObj.ReturnStatus = true);
    {XDocument.UI.Alert("Form was uploaded succesfully.");
    }
    try
    {
    Application.ActiveWindow.Close(true);
    }
    catch(e)
    {
    XDocument.UI.Alert(e.description);
    }
    }
  • 11-17-2006 06:57 AM In reply to

    Re: Close Infopath after submit does not work.

    Yeah!

    I posted on the Microsoft Dev forum a little bit of knowledge I didn't know previously. Here's how I implemented it:

    1. I diagrammed the worklfow and identified five states of processing.
    2. I created all my fields and layout, placing them in Sections related to each state of processing.
    3. I coded each of the sections with Conditional Formatting to Hide or Disable controls depending on the currrent state.
    4. I coded the "Submit" buttons in those sections with Rules to set the State field after each submit. There is also code behind each button similar to what you put in your last post; i.e., a generic Submit.

    Now here is what I didn't know at first, but later found out. The Submit rules that you set up in Tools...Submitting Forms with Submit To set to "Custom submit using rules" are processed AFTER each of the generic Submit statements in the controls. So . . . I set those rules to submit to the appropriate data connection depending on the value of the State field. It's amazing how easy it is once you know what you're doing. ;-)

    I now need a couple of things:

    1. A simple routine to trap a failed submission and give control back to the user.
    2. A simple piece of code that sets the value of the State field AFTER successful submission. Right now, I'm setting in the Rules of the Submit button, so if the Submit fails that field is erroneously saying it was submitted.
  • 12-03-2006 11:28 PM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-28-2006
    • California
    • Posts 44

    Re: Close Infopath after submit does not work.

    Hi,

    I am using the following code, but it gives me an error on Submit request. I dont want to use the Main submit. I want to be able to submit using the submit button.

    function XDocument::OnSubmitRequest(eventObj)
    {
    if (XDocument.Errors.Count > 0)
    {XDocument.UI.Alert("Required information is missing as indicated by the red asterisk(s).") ;
    return;
    }
    try
    {
    XDocument.Submit()
    Application.ActiveWindow.Close(true);
    }
    catch(e)
    {
    XDocument.UI.Alert(e.description);
    }

    I would like to submit using an Email data connection.
    Will the following code work and where should i place it?

    string submitDestination = XDocument.DOM.selectSingleNode("my email address");
    EmailAdapter emailSubmit = (EmailAdapter)thisXDocument.DataAdapters["EmailSubmit"];
    emailSubmit.Submit();

    Thanks for any help!!!!
  • 12-05-2006 02:52 AM In reply to

    • ilse
    • Not Ranked
    • Joined on 10-27-2006
    • Posts 18

    Re: Close Infopath after submit does not work.

    But if you make a button, using that custom code but with the OnClick, adding a rule to submit using the main submit (which in your case is an email connection)you should be fine. It will submit on clicking the button to email and close the program when it is send.
  • 12-05-2006 02:58 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-28-2006
    • California
    • Posts 44

    Re: Close Infopath after submit does not work.

    I have figured the email submit and how to submit to the sharepoint library. But I get an object error if i try to submit both using the same button. Either one only works.

    Also how can i add more forms in my code. I know we use the .Open function. If anyone has anyclues. let me know.

    Thanks..
Page 1 of 2 (16 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.