Hi,
I have two supposing simple issues which I'm having problems correcting.
If a add a button to the form and write some custom code (See below) to submit some data via a REST Web Service data connection. The code runs but somehow fires the URL twice to the web service.
I've also recreated similar functionality using Rules on a button and some concat formulas and exactly the same thing happens when I the run the data using the Query Data Action, it fires the URL twice at the web service.
How can I stop this.
Secondly, if I use the custom code route, it work correctly the first time it pressed except for the double fire issue, but the second time I click the button the InfoPath internal system throws up an issue. See screen shot below.
Any help would be appreciated.
Rob
namespace SubmitTest
{
public partial class FormCode
{
// Member variables are not supported in browser-enabled forms.
// Instead, write and read these values from the FormState
// dictionary using code such as the following:
//
// private object _memberVariable
// {
// get
// {
// return FormState["_memberVariable"];
// }
// set
// {
// FormState["_memberVariable"] = value;
// }
// }
// NOTE: The following procedure is required by Microsoft InfoPath.
// It can be modified using Microsoft InfoPath.
public void InternalStartup()
{
//EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
((ButtonEvent)EventManager.ControlEvents["SaveDataPoint"]).Clicked += new ClickedEventHandler(SaveDataPoint_Clicked);
}
/*public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
// If the submit operation is successful, set
// e.CancelableArgs.Cancel = false;
// Write your code here.
MessageBox.Show("Submit Function Start");
//SaveDataPoint_Clicked(sender);
MessageBox.Show("Submit Function End");
}*/
public void SaveDataPoint_Clicked(object sender, ClickedEventArgs e)
{
try
{
FileQueryConnection fqcConnection = (FileQueryConnection)this.DataConnections["TestREST"];
string fqcFileLocation = fqcConnection.FileLocation;
MessageBox.Show("fqcFileLocation " + fqcFileLocation);
fqcFileLocation = fqcFileLocation + "?TestName='HugeArse'";
fqcConnection.FileLocation = fqcFileLocation;
fqcConnection.Execute();
}
catch (Exception ex)
{
MessageBox.Show("NewDataPoint_Clicked: Error " + ex);
}
}
}
}

