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/