<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Using code and rules- Can I print and submit form with one button click?</title><link>https://www.infopathdev.com:443/forums/thread/79887.aspx</link><pubDate>Wed, 27 Jun 2012 15:14:45 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79887</guid><dc:creator>Doreen</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79887.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=79887</wfw:commentRss><description>&lt;p&gt;Thank you - after a little research&amp;nbsp;I figured out that rules run before code.&amp;nbsp; My rules were ending with submit and close&amp;nbsp;which was why the printing didn&amp;#39;t happen.&amp;nbsp;&lt;/p&gt;&lt;p&gt;I like your idea and I would be interested how to write c# code to set a value on a node (like a button?) because it may be the solution to my newest problem.&amp;nbsp; In the meantime I took out the submit action rules&amp;nbsp;which included closing the form,&amp;nbsp;and left in the rules which populated the other fields.&amp;nbsp; Now I&amp;nbsp;programmatically submit the form:&lt;/p&gt;&lt;p&gt;On the&amp;nbsp;button click event, after the print call,&amp;nbsp;I call a method to submit the form (FormEvents_Submit()) and it workswith warning exception error which I&amp;nbsp;catch using try/catch.&amp;nbsp; It doesn&amp;#39;t stop the form from printing or submitting &amp;quot;an object reference is not set to an instance of an object&amp;quot; which I should investigate more....&lt;/p&gt;&lt;p&gt;---edit: I removed the rest of this post because it relates to a different problem. Will post a new thread for it.&lt;/p&gt;</description></item><item><title>Re: Using code and rules- Can I print and submit form with one button click?</title><link>https://www.infopathdev.com:443/forums/thread/79881.aspx</link><pubDate>Wed, 27 Jun 2012 11:24:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79881</guid><dc:creator>ErnestoM</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79881.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=79881</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi-&lt;/p&gt;&lt;p&gt;Rules execute before code, so the rules are executing, the form is submitted, perhaps closes, and then the Print command has no chance to execute. &lt;/p&gt;&lt;p&gt;You could add a node to your form schema and add to it the rules that you want to run after code. Your button (without rules) will now call the code only. Then after all your code has executed, have the code set the value of the new node (the one that now has all the rules). This will be the trigger on the new node to execute the rules.&lt;/p&gt;&lt;p&gt;Good luck!&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Using code and rules- Can I print and submit form with one button click?</title><link>https://www.infopathdev.com:443/forums/thread/79868.aspx</link><pubDate>Tue, 26 Jun 2012 17:52:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:79868</guid><dc:creator>Doreen</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/79868.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=79868</wfw:commentRss><description>&lt;p&gt;I am using IP 2007.&amp;nbsp; It seems if I have simple code behind &amp;nbsp;like:&amp;nbsp;&amp;nbsp;&lt;strong&gt;this.print();&lt;/strong&gt; on a button control &lt;em&gt;and &lt;/em&gt;rules on the same control, only the rules run??&lt;/p&gt;&lt;p&gt;Ideally I&amp;#39;d like to print and submit with one click but my submit rules need to set several other field values first. My form is submitted correctly but the print method is ignored.&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;p&gt;I tryed coding a message box in the button control with the submit rules to ask the user to print instead but that behaves the same as if I&amp;#39;d just coded &lt;strong&gt;this.print();.&lt;/strong&gt;&amp;nbsp; So it seems to me no matter what code I give it, it is ignored.&amp;nbsp; If I put the code alone on a separate button control, it works just fine.&lt;/p&gt;&lt;p&gt;So my question is - is there a way to throw code and rules into action on one control - preferably a button control?&lt;/p&gt;</description></item></channel></rss>