coding forming to close infopath on submit - InfoPath Dev
in

InfoPath Dev

coding forming to close infopath on submit

Last post 01-27-2011 12:15 PM by HamishAhern. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 02-05-2009 09:01 PM

    coding forming to close infopath on submit

    In InfoPath 2007, I have a form that has a submit button and I want to close the instance of infopath after it has been submitted. I have read the following two forums but they are not very clear on how to exactly make this happen, just detailing the code and not all the steps re where to put the code exactly.

    http://www.infopathdev.com/forums/p/918/3387.aspx#3387 

    http://www.infopathdev.com/forums/p/2262/9360.aspx#9360

    I want the instance of Infopath to be closed after the form has been submitted (via email, this part is working fine).

    I have inserted the button control and right clicked for button properties, now here button properties dialog window, I can select the action submit(the only other option is rules and custom code) and then I can choose below that submit options. From there I select to allow users to submit by email, follow the GUI all they way through and it works fine.

    How do add rules/code from this point on to close the infopath instance? A detailed reply or a form with a working sample would be much appreciated, thankyou.

  • 02-05-2009 09:25 PM In reply to

    Re: coding forming to close infopath on submit

    Hi Aredubbya and welcome!

    Go to Tools->Submit Options and choose Advanced. Thre is a "After submit..." dropdown. Choose "Close the form". No coding required for IP2007.

    Patrick Halstead
    Project Manager at Qdabra
  • 02-06-2009 01:22 AM In reply to

    Re: coding forming to close infopath on submit

    Hi Patrick,

    Thanks for a prompt reply.  I already has this enabled and this does work ONLY in regards to closing the form, it does not however close InfoPath the application. What you get is the image below.InfoPath after submit form by email

     

     

     

     

     

     

     

     

     

     

    I want the InfoPath form to close the InfoPath application too (like you would normally by clicking on the "X" in the top right hand coner or pressing "ALT F4") after the form has been submitted by email. There has to be a way to do this.

    How do you do this?

  • 02-06-2009 03:57 AM In reply to

    Re: coding forming to close infopath on submit

    Hi,

    You have to use below code in submit button OnClick event after submitting form.

    thisXDocument.View.Window.Close(true);

    Here is the sample attachment xsn.

    Rajitha
  • 02-09-2009 12:52 AM In reply to

    Re: coding forming to close infopath on submit

    Hi Raijtha,

    Thanks for the reply, unfortuately your test.xsn form wouldn't open. The error said

    "This form cannot be opened becasue it requires domain level permissions and it currently has restricted permission.To fix this problem, open the form from the location it was published to.

    Published location:file ///C:\Documents and Settings\rajithas.GGK\Desktop\Test.xsn"

    Cuold you try again or outline how set up an onclick event for after submission here? I appreciate your help. Thanks.

     

    Filed under: ,
  • 02-09-2009 01:36 AM In reply to

    Re: coding forming to close infopath on submit

    Hi,Save the attachment and open it in design mode. Then click on Preview. Then it will work.

     

    Rajitha
  • 02-09-2009 02:23 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: coding forming to close infopath on submit

    Hi,

    You can use below steps to close the form instead of using Code.

    1.       Open button Properties.

    2.       Select “rules and Custom Code” option in the Action dropdown.

    3.       Click on Rules button and click on Add button.

    4.       Click on Add Action button.

    5.       Add first Rule to submit the form.

    6.       Add second rule to close the form.  (Click on Add Action and select “Close the form” from Action dropdown.)

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 08-24-2009 04:03 AM In reply to

    • Razor
    • Not Ranked
    • Joined on 02-01-2006
    • Posts 16

    Re: coding forming to close infopath on submit

    I'm having the same problem but I.m using Infopath 2007 with the 2007 object model and managed C# code. Could someone enlighten me on how I should code to close both the form and Infopath?

    Regards Razor

  • 01-27-2011 12:15 PM In reply to

    Re: coding forming to close infopath on submit

    did anybody find a solution to his yet?   I made a solution:

    1) Use windows API to disable the form close button...    http://social.msdn.microsoft.com/Forums/en/sharepointinfopath/thread/257f186f-3ab3-4ac4-9553-f71d100ad297
    2) Disable the toolbars using code from google..
    3) put a button on the form for the user to close the app
    4)  use Application.Exit() to quit InfoPath.

    public void btnExit_Clicked(object sender, ClickedEventArgs e){
    // your save code here.

    //re-enable toolbars before you exit
    HideAllToolbars(
    true);
    //Exit App
    Application.Quit();
    }

    void HideAllToolbars(bool flag)

    {


    CommandBars myCommandBars = this.Application.ActiveWindow.CommandBars as CommandBars;

    CommandBar myCommandBar = (this.Application.ActiveWindow.CommandBars as CommandBars).ActiveMenuBar;

    foreach (CommandBar item in myCommandBars)

    {

    //MessageBox.Show(item.Name.ToString() + " " + item.Type.ToString() + " " + item.Index.ToString());

    if (flag == true && (item.Type == MsoBarType.msoBarTypeMenuBar || item.Type == MsoBarType.msoBarTypeNormal))

    {

    item.Enabled =
    false;

    }

    }

    }

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.