<?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>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/65827.aspx</link><pubDate>Fri, 08 Apr 2011 18:03:44 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:65827</guid><dc:creator>ashoke</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/65827.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=65827</wfw:commentRss><description>&lt;font face="Calibri" size="3"&gt;Hi - I have solved the issue with minor tweak. I needed the button to pop up Save As dialogue box all the time. I thought someone might be benefitted from my codes which are done on IP 2007 connected to Access db. Thanks, Ash&lt;/font&gt;&amp;nbsp;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;SaveFileDialog&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; saveas = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;SaveFileDialog&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;();&lt;/p&gt;saveas.AddExtension = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;true&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;saveas.DefaultExt = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;xml&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/p&gt;saveas.Filter = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;XML Documents (*.xml)|*.xml&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;// Set a default file name from entered data &lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; form_ID = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/d:top/@ID&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NamespaceManager).Value;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (form_ID == &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; || form_ID == &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;form_ID = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;New Project&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;saveas.FileName = form_ID;&lt;/p&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;DialogResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; result = saveas.ShowDialog();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (result == &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;DialogResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.OK)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.SaveAs(saveas.FileName);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/65759.aspx</link><pubDate>Wed, 06 Apr 2011 07:06:44 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:65759</guid><dc:creator>renato</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/65759.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=65759</wfw:commentRss><description>&lt;p&gt;Unfortunately I&amp;#39;m not that familiar with the&amp;nbsp;IP2007 API, nor with DB-connected forms. Actually I would like to deepen that second subject as I&amp;#39;m starting development on a DB-connected form (though still on IP 2003 filler forms). Specifically I&amp;#39;m wondering if I still need to save the forms&amp;#39; XML, and wether/how the form XML is linked to the DB table record... Sorry if I answer with a question...&lt;/p&gt;</description></item><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/65756.aspx</link><pubDate>Tue, 05 Apr 2011 19:10:07 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:65756</guid><dc:creator>ashoke</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/65756.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=65756</wfw:commentRss><description>&lt;p&gt;Hi Renato, Thanks for posting your solution code. I&amp;#39;m in a similar situation where I need to add a button that will pop up a window for Save As. Mine is in InfoPath 2007 full trust connected to Access db. For some reasons, DocActionEvent is not supporting. It&amp;#39;s driving me nuts. Any help would be highly appreciated? Thanks for your help in advance. Ash&lt;/p&gt;</description></item><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/61929.aspx</link><pubDate>Fri, 03 Dec 2010 13:55:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61929</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61929.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=61929</wfw:commentRss><description>&lt;p&gt;That&amp;#39;s cool. Wonder if full trust is still required though. &lt;/p&gt;
&lt;p&gt;One more idea that is codeless and doesn&amp;#39;t require full trust: add a Submit button and label it Save. You can set the name programmatically based on unique keys in the form. Assumes it is going to a server though and won&amp;#39;t work to save locally.&lt;/p&gt;</description></item><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/61927.aspx</link><pubDate>Fri, 03 Dec 2010 12:26:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61927</guid><dc:creator>renato</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61927.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=61927</wfw:commentRss><description>You&amp;#39;re right Patrick, that is just a way to make it easier and clearer for users, which are potentially hundreds, maybe 1 thousand. I&amp;#39;m trying to have &amp;quot;submit&amp;quot; and &amp;quot;save&amp;quot; buttons close in the form and reduce the number of possible choices for users, that&amp;#39;s the only point. Anyway a found a post on a different site which helped me a bit. I&amp;#39;m posting my solution for the Onclick event of the save button, in case anyone is interested:


public void CTRL108_8_OnClick(DocActionEvent e)
        {
            // try a straight save (will work if document had already been saved
            try { thisXDocument.Save(); }
            catch (Exception ex1)
            {
                SaveFileDialog saveas = new SaveFileDialog();
                saveas.AddExtension = true; ;
                saveas.DefaultExt = &amp;quot;xml&amp;quot;;
                saveas.Filter = &amp;quot;XML Documents (*.xml)|*.xml|All Files (*.*)|*.*&amp;quot;;
                // Set a default file name from entered data
                string projectTitle = thisXDocument.DOM.selectSingleNode(&amp;quot;/my:myFields//blabla&amp;quot;).text;
                if (projectTitle == null || projectTitle == &amp;quot;&amp;quot;)
                {
                    projectTitle = &amp;quot;New Project&amp;quot;;
                }
                saveas.FileName = projectTitle + &amp;quot; - Gate 4&amp;quot;;
                DialogResult result = saveas.ShowDialog();
                if (result == DialogResult.OK)
                {
                    thisXDocument.SaveAs(saveas.FileName);
                }

            }
        }</description></item><item><title>Re: Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/61924.aspx</link><pubDate>Fri, 03 Dec 2010 11:46:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61924</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61924.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=61924</wfw:commentRss><description>&lt;p&gt;Hi Renato,&lt;/p&gt;
&lt;p&gt;Stupid question but why not use the out-of-box support for save? Why do you need to make this a button? &lt;/p&gt;
&lt;p&gt;We&amp;#39;ve developed and delivered hundreds of InfoPath forms. We&amp;#39;ve done a lot of work to customize Save for offline scenarios (for example, adding conflict resolution detection, etc.) but we&amp;#39;ve never ever tried to popup a Windows save dialog. The other issue with forcing this is that you will have to be full trust which is not a best practice. I recommend just teaching the users to use the default controls. &lt;/p&gt;
&lt;p&gt;Sorry for the lack of a solution.&lt;/p&gt;</description></item><item><title>Custom Save Button</title><link>https://www.infopathdev.com:443/forums/thread/61922.aspx</link><pubDate>Fri, 03 Dec 2010 09:49:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61922</guid><dc:creator>renato</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61922.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=61922</wfw:commentRss><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to define custom buttons on my Infopath 2003 (filler) form to achieve simpler submit/save operations for users. My scenario is as follows:&lt;/p&gt;
&lt;p&gt;1) User may start filling a new form: in this case I want them to be able to a) Save the form locally (a kind of a draft) or b) submit the form (to a SP library)&lt;/p&gt;
&lt;p&gt;2) User may open and modify a form which is already on the SP library; in that case I want them to be able to c) save their changes.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m able to discriminate 1) and 2) - also submitting the form works fine, saving changes works fine, but where I&amp;#39;m struggling is on a) making them able to save a local draft, because thisXDocument.Save() will only work if the form is already saved (either locally or on the SP library), whereas thisXDocument.saveas requires a path to the file where to save the form, while I want the save as dialog box to pop up (the first time - as for any office document). That would be what the default save button does, but I&amp;#39;m trying to achieve the same on a custom button to facilitate users which I&amp;#39;m sure would be struggling with Submit/Save...&lt;/p&gt;
&lt;p&gt;At the end what I&amp;#39;m looking for is a custom save button which behaves as the default infopath save button. Any help is very appreciated, thanks&lt;/p&gt;
&lt;p&gt;Renato&lt;/p&gt;</description></item></channel></rss>