Closing infopath form either by code or custom Rules - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Closing infopath form either by code or custom Rules

Last post 11-17-2011 09:06 AM by bblanke. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-17-2008 11:15 AM

    Closing infopath form either by code or custom Rules

    Hi All,

     I have a infopath 2007 form where I am trying to close the form programatically in C#. I was using this.Submit() to close the form on click of a button.

     Now I have changed all the connections to the UDC Library and this function to close the form stopped working. Although there is no relation to the this.Submit() and the UDC Library, it is the only change that I have done.

     I can use the Rule to close the form, but it is closing the form before the code behind code is getting called, which inturn is calling an event handler.

    Alteast is there a way we could ensure that all data is properly passed to the event handler before the form is getting closed?

     Can anyone throw some light on what could be done to rectify this issue?

    Thanks a lot in advance :)

     

    Regards Sridhar

  • 10-17-2008 10:19 PM In reply to

    Re: Closing infopath form either by code or custom Rules

    Hi,

    you can use the following code line to close the form.

    thisXDocument.View.Window.Close(true);

    hope this will help to you.

    Swathip
    www.ggktech.com
  • 10-22-2008 08:49 AM In reply to

    • Bhavesh
    • Top 500 Contributor
      Male
    • Joined on 05-01-2008
    • Atlanta
    • Posts 40

    Re: Closing infopath form either by code or custom Rules

    Hi,

    When you have some code behind on the button click along with the rule for closing the form, rule will be executed before the code behind, so what you can do is remove the rule for closing the form from the button. Let the form execute the code behind logic then create a new blank view and switch the view programatically to a new blank view with one button for "close form". add rule for closing the form on this new view.

    For switching view programatically you can add this.ViewInfos.SwitchView(viewname); after your code.

    Hope this will help you.

    Bhavesh

  • 10-22-2008 11:40 PM In reply to

    Re: Closing infopath form either by code or custom Rules

    Hi,

    you can use the following code for closing the form

    XDocument.View.Window.Close(true);

    if you want to close the whole InfoPath application you can use

    Application.ActiveWindow.Close();

     

    Thanks,
    Sandhya


  • 10-12-2010 11:47 AM In reply to

    Re: Closing infopath form either by code or custom Rules

    what I did was set a field to a specific value at the end of the custom code and have the "close form" rule trigger when that field is set to the specific value. the problem then is the rule isn't checked when the field is set so the button has to be clicked twice before the form closes. It's a squirly work around and I'm going to try the programmatic solutions in this thread ina  sec but in case it's more along the lines of what you're trying to do it's another option for you :)

  • 10-12-2010 11:53 AM In reply to

    Re: Closing infopath form either by code or custom Rules

    that code didn't work for me, maybe I'm missing a reference, using statement, or it isn't meant to work in infopath 2010?

    I'll keep looking and fiddling

  • 10-12-2010 02:25 PM In reply to

    Re: Closing infopath form either by code or custom Rules

     Hi Brian, you probably use C# or VB try

    this.Close() or this.Application.Quit()

    For VB replace this for me.

  • 10-13-2010 01:29 PM In reply to

    Re: Closing infopath form either by code or custom Rules

    somehow I wasn't getting all the microsoft.office.infopath methods, re-added the reference and now I have what I need, thanks

  • 10-13-2010 01:49 PM In reply to

    Re: Closing infopath form either by code or custom Rules

    this.Application.ActiveWindow.Close(); will close the window (as well as the form) where this.Application.Quit();  might have security issues,

  • 11-17-2011 09:06 AM In reply to

    • bblanke
    • Top 500 Contributor
      Male
    • Joined on 11-12-2009
    • Milwaukee, WI
    • Posts 32

    Re: Closing infopath form either by code or custom Rules

    I have noticed this only happens during events other than clicked_events and context_changed_event. Is there any way to call this during a changed_event, or is there a way to call the context_changed event or clicked_event through code?
    Brandon Blanke
    Technical Analyst / Quad Graphics
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.