<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Web Services</title><link>https://www.infopathdev.com:443/forums/48.aspx</link><description> </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>InfoPath 2010 and REST web services, custom code button firing twice and second click fires error</title><link>https://www.infopathdev.com:443/forums/thread/95770.aspx</link><pubDate>Mon, 10 Feb 2014 08:12:53 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:95770</guid><dc:creator>The_Muns</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/95770.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=48&amp;PostID=95770</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have two supposing simple issues which I&amp;#39;m having problems correcting.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;I&amp;#39;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.&lt;/p&gt;
&lt;p&gt;How can I stop this. &lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Any help would be appreciated.&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;pre class="prettyprint"&gt;&lt;p&gt;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[&amp;quot;_memberVariable&amp;quot;];
        //     }
        //     set
        //     {
        //         FormState[&amp;quot;_memberVariable&amp;quot;] = 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[&amp;quot;SaveDataPoint&amp;quot;]).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(&amp;quot;Submit Function Start&amp;quot;);
            //SaveDataPoint_Clicked(sender);
            MessageBox.Show(&amp;quot;Submit Function End&amp;quot;);
        }*/
        public void SaveDataPoint_Clicked(object sender, ClickedEventArgs e)
        
        {
            try
            {
                FileQueryConnection fqcConnection = (FileQueryConnection)this.DataConnections[&amp;quot;TestREST&amp;quot;];
                string fqcFileLocation = fqcConnection.FileLocation;
                MessageBox.Show(&amp;quot;fqcFileLocation  &amp;quot; + fqcFileLocation);
                fqcFileLocation = fqcFileLocation + &amp;quot;?TestName=&amp;#39;HugeArse&amp;#39;&amp;quot;;
                fqcConnection.FileLocation = fqcFileLocation;
                fqcConnection.Execute();
            }
            catch (Exception ex)
            {
                MessageBox.Show(&amp;quot;NewDataPoint_Clicked: Error &amp;quot; + ex);
            }
        }
    }
}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt="INfoPath cannot be run for the following DataObject. The file is not a valid XML file. Not enough storage available tp process this command" src="http://social.msdn.microsoft.com/Forums/getfile/-1" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction Microsoft.Office.InfoPath.Internal.FileQueryConnectionHost.Execute" src="http://social.msdn.microsoft.com/Forums/getfile/-1" /&gt;&lt;/p&gt;</description></item></channel></rss>