I have a form with 2 data connections, email and sql database. On submitting the form using the submit button on the toolbar it works just fine. I use 'custom action rules' in the submit options. Also a pop up message is displayed (using C# managed code that is triggered when one of the required fields on the form is filled out), once the user clicks the ok button on the pop up message both data connections then submit just fine. That is the flow and what I want.
My problem is now I must add a submit button to the form itself while maintaining the same flow as above. The submit button on the form works just fine when submitting the email and sql data sources using the 'rules and custom code' option. But when I try to display the pop up message before submitting the form, I have to click the submit button twice, once to generate the pop up message and once to submit the data connections. Also the "form submitted successfully" message is not being displayed when the form is submitted to the sql database.
The control flow of the form behaves differently when using the submit button on the toolbar versus using a submit button on the form.
My solution was to use the 'submit' action on the button property on the form and do this entirely in managed code, C# using the 'Perform custom action using Code'.
I can display the pop up message, then send the email but am unable to submit to the sql database even though I get the "form submitted successfully".
Here is the code for the data connections;
EmailSubmitConnection ec = (EmailSubmitConnection)(this.DataConnections["Email Submit"]);
DataConnection mc = (DataConnection)this.DataConnections["Main connection"];
try{ ec.Execute(); e.CancelableArgs.Cancel = false;} catch {e.CancelableArgs.Cancel = true;}
try{ mc.Execute(); e.CancelableArgs.Cancel = false;} catch {e.CancelableArgs.Cancel = true;}
Any help will be greatly appreciated, Sorry I don't know how to use the tags yet.