Programatically close web enabled form after manual submit - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Programatically close web enabled form after manual submit

Last post 11-11-2010 11:43 PM by eliasen. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 10-22-2010 04:08 AM

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Programatically close web enabled form after manual submit

    Hi all

    I have an InfoPath 2007 form, which is web enabled and deployed to Forms Server 2007.

    On the form I have a button. What I want to happen when the button is pressed is this:

    1. My custom code behind should be executed. The custom code calls an external aseembly (common to ALL my InfoPath forms) which has a method that includes a dataconnection.Execute which will submit the form.

    2. Close the form IF the submit went well.

    Currently, I have a code behind and a rule on the button. What I am trying to get working is that the code behind sets a status flag on the form to "Success" and then executes the data connection. If an exception is thrown, I set the status flag to something else ("Failed") and rethrow the exception. In the rule of the button I then check this status field in the condition of the rule and if it is set to Success I close the form. What happens is, that the form is not closed uppon succesfully execution of the data connection. I am not sure in what order the code is run; Is the rule fired first or is the .NET code behind? It appears that the .NET code IS fired... and if the form was closed in the rule, then I wouldn't expect that to happen. So that means the rule is fired last. On the other hand the value set in one of the fields is not present upon validation of the condition of the rule, so that means the rule is fired first... or that changes made in the code behind are not visible to the rule after the .NET code has finished...

    So basically, I want to know:

    1. Can I close the form from my .NET code behind? I have tried different things, with Window.Close(); but keep getting an "MethodNotImplemented" exception or something like that.

    2. What is fired first? Rules or code behinds? if code behind, then how do I make my changes to the data source visible to the rule that is fires afterwards?

    Thanks!

    --
    eliasen, Microsoft MVP, blog: http://blog.eliasen.dk

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 10-25-2010 12:07 AM In reply to

    Re: Programatically close web enabled form after manual submit

    Hi Eliasen,

    Yeah, so, rules are fired first. You could use xdExtension in the condition of the rule to call code. That might be better than the status flag since you won't pollute the main data source. Try that and let us know if it works. Search for xdExtension if you have questions. Greg's samples should help.

    Best,

    Patrick Halstead
    Project Manager at Qdabra
  • 10-26-2010 04:40 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Hi Patrick

    Thanks.

    Well... Not what I was looking for :-)

    I'll have to look into that, but from the very few things I just found, it seems I need to manually edit the XSL file. My solution is suppsoed to be a platform for several hundred different forms, and the developers of the form are not supposed to be technical. So I am worried if this will disqualify lots of potential users from using the platform...

    But I suppose, if there is really no way of closing the form from code, then this is what I have to do...  Bummer. I'll get back to you on this once I have looked into xdExtension and let you know what I have decided.

    Thanks

    --
    eliasen

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 10-26-2010 09:05 PM In reply to

    Re: Programatically close web enabled form after manual submit

    xdExtension has nothing to do with the XSLT. You add it to the condition of the rule to allow you to call code.

    Patrick Halstead
    Project Manager at Qdabra
  • 10-29-2010 07:46 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Hi

    I must have misunderstood something then. I looked a tthis: http://www.infopathdev.com/blogs/greg/archive/2004/09/15/Use-Code-to-Determine-a-Rule-Condition.aspx - but I see now that this is a very old post. So probably it only applies to InfoPath 2003?

    I'll play around with it this weekend...

    Thanks

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 10-29-2010 07:54 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Hi again

    From this one: http://www.infopathdev.com/forums/p/8479/30623.aspx I gather that the xdExtension is not supported for browser enabled forms?

    --
    eliasen

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 10-29-2010 08:21 AM In reply to

    Re: Programatically close web enabled form after manual submit

    Does your code run in a custom submit event? Check out this article -- it suggests that the only exception to rules running before code is the "Close this form" rule on submit options. Seems like it may be worth a try?
    Hilary Stoupa

  • 11-02-2010 06:18 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Hi

     I gather that xdExtension does not work from web enabled forms. I see others complaining about it (http://www.infopathdev.com/forums/p/10426/37397.aspx#37397) but haven't found a solution.

    Anwyay, this means that I get an error when uploading the form to forms server - translated from Danish, it sounds like this:

    "The following expression could not be parsed due to syntax errors or because it uses a namespace prefix not defined, or a feature not supported: xdExtension: SubmitBool ()."

     SubmitBool is the method in my code behind...

    Does anyone know how to get xdExtension to work in browserenabled forms?

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 11-02-2010 06:34 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Hi Hilary.

    That may look promising... I'll have to look into it. And I'll get back to you.

    Thanks.

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
  • 11-02-2010 08:20 AM In reply to

    Re: Programatically close web enabled form after manual submit

    Hi,

    I've got this question in my mind a few weeks ago.

    Since you use managed code, I advise you to use redirection code:

    HttpContext.Current.Response.Redirect(strSource, false);

    where "strSource" is the value of the source in the url of the web-browser form.

    I see two reasons to use this method:

    • If an error occured before your line of code, this technic allow you te see the error on the screen. If you use rules to close the form, you will not see the error fired on screen.
    • You can redirect on the page that you want.

     

    RĂ©mi MATAYRON / MVP InfoPath
    Visit my blog : Infopath Blog
    Filed under:
  • 11-11-2010 11:43 PM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Re: Programatically close web enabled form after manual submit

    Patrick Halstead:

    Yeah, so, rules are fired first.

    Hi Patrick

    Yesterday I got a reply from MS at http://social.msdn.microsoft.com/Forums/en-US/sharepointinfopath/thread/f368b51c-bbc0-4529-af59-c9f63dc6a312 - according to him, rules are not fired first for web enabled forms.

    Who is right?

    Thanks!

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.