InfoPath 2010 and REST web services, custom code button firing twice and second click fires error - InfoPath Dev
in

InfoPath Dev

InfoPath 2010 and REST web services, custom code button firing twice and second click fires error

Last post 02-10-2014 12:12 AM by The_Muns. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 02-10-2014 12:12 AM

    InfoPath 2010 and REST web services, custom code button firing twice and second click fires error

    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); } } } }

     

     

    INfoPath cannot be run for the following DataObject. The file is not a valid XML file. Not enough storage available tp process this command

    Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction Microsoft.Office.InfoPath.Internal.FileQueryConnectionHost.Execute

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.