Hello,
I am developing a web-based form with InfoPath 2007 that is hosted in MOSS (InfoPath Forms Services, FormServer.aspx)
The form is used in a workflow provided by a 3rd party product that integrates with MOSS and InfoPath.
Rather than using the toolbar with the "Send" button provided by InfoPath, the form uses buttons inside it, with actions such as "Submit", "Accept", "Reject", "Return to sender", etc. depending on the view used by the workflow.
The fields of the form have complex business validations that require code to perform them. Some of them must be performed before the form is submitted (not tied to the Changed or Validating events of fields).
After performing those validations, if they pass, the form must be submitted and closed (redirecting to previous web page or to a custom one). I have everything done except the part of closing the form:
The buttons have the action "Rules and custom code" and in the custom code I perform the validations and if successful I execute a connection to submit the form. At that point, I would like to close the form programmatically but it seems (searching the web) that there is no way to close programmatically a web-based form handled by FormServer.aspx. I have tried adding a reference to System.Web and getting the HttpContext and then all kinds of tricks such as HttpContext.Response.Redirect or HttpContext.Server.Transfer. All of them either are ignored or cause an error (InfoPath Form Service shows an error).
It seems that the only way to close a web-based form is to set the button action to "Submit", and in the Submit Options:
- Set the Custom Code radiobutton
- In the Advanced section, set the value "Close the form" in the combobox.
But using the custom code radiobutton I get the same FormEvents_Submit event handler for all the buttons, and it seems that there is no way to get the button that was clicked, so I can't do different things depending on the button that was clicked.
So, is there a way in web-based forms of
a) having different submit buttons with custom code
b) that perform different validations (depending on the button clicked) before actually submitting the form through a connection and
c) then closing it (or redirecting it to some custom web page)?
Thanks in advance,
Carlos Quintero
Visual Basic MVP