<?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: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13264.aspx</link><pubDate>Mon, 28 Nov 2005 22:55:52 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13264</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13264.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13264</wfw:commentRss><description>Save requires higher security. Why do you need to store the value in the XDocument DOM when you can always query the URI when you open the file?&lt;br /&gt;&lt;br /&gt;Patrick Halstead [InfoPath MVP]&lt;br /&gt;InfoPathDev</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13263.aspx</link><pubDate>Tue, 22 Nov 2005 10:27:03 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13263</guid><dc:creator>frala</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13263.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13263</wfw:commentRss><description>Hi,&lt;br /&gt;&lt;br /&gt;The problem I have is not the same but it is regarding the same function.&lt;br /&gt;&lt;br /&gt;The form contents is saved using eventObj.PerformSaveOperation(); method.&lt;br /&gt;As the user can modify the file name, I would like to save this new file name (a default one is set when the dialog box is opened) in the XDocument.&lt;br /&gt;I use eventObj.XDocument.URI; to get the new file name but saved XML document is not updated (I agree with that).&lt;br /&gt;&lt;br /&gt;How can I do that ?&lt;br /&gt;I tried a XDocument.Save(); but it doesn't work (error message).&lt;br /&gt;If I use again eventObj.PerformSaveOperation(), a new dialog box is opened. Unfortunately the IsSaveAs property is read-only.&lt;br /&gt;&lt;br /&gt;Thanks for your help.</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13262.aspx</link><pubDate>Wed, 22 Jun 2005 15:25:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13262</guid><dc:creator>ScottAtRVC</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13262.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13262</wfw:commentRss><description>Hi Paul.  &lt;br /&gt;&lt;br /&gt;Sorry for the delay, i have been out of the office for a few days.&lt;br /&gt;&lt;br /&gt;Here you go &lt;a href='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkIntroducingInfoPathDevelopment_HV01073333.asp' target='_blank' title='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkIntroducingInfoPathDevelopment_HV01073333.asp'&lt;a target="_blank" href=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkIntroducingInfoPathDevelopment_HV01073333.asp&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkIntroducingInfoPathDevelopment_HV01073333.asp&lt;/a&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;thisXDocument is not the object in script.  Use XDocument;&lt;br /&gt;GMSRef = XDocument.DOM.selectSingleNode("my:myFields/my:field1").text&lt;br /&gt;&lt;br /&gt;this works for me :)&lt;br /&gt;&lt;br /&gt;Cheers.  Scott.</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13261.aspx</link><pubDate>Fri, 17 Jun 2005 13:48:11 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13261</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13261.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13261</wfw:commentRss><description>I am simply looking to have a form filed with the unique reference id as entered into the form as the filename and to specify exactly where it is saved to.&lt;br /&gt;&lt;br /&gt;The first obvious choice was as per the link in my first post. If this is not the best way to go can you identify another method. The script is provided by infopath with the sub name etc declared. Evidently the script is not getting details of what thisxdocument is.&lt;br /&gt;&lt;br /&gt;I am really stuck with this and if there is an alternative way to do it then I'll use it.&lt;br /&gt;&lt;br /&gt;Many thanks&lt;br /&gt;&lt;br /&gt;Paul</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13260.aspx</link><pubDate>Fri, 17 Jun 2005 12:55:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13260</guid><dc:creator>ScottAtRVC</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13260.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13260</wfw:commentRss><description>Sorry my apologies.  I see you are using script and not managed code.  I have not used InfoPath scripting.  Initial questions that spring to mind are;&lt;br /&gt;* is the thisXDocument object definatly set?&lt;br /&gt;* does the eventObj parameter provide the XDocument?&lt;br /&gt;&lt;br /&gt;Sorry i cant be of much more use.  Cheers. Scott.&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13259.aspx</link><pubDate>Fri, 17 Jun 2005 12:38:50 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13259</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13259.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13259</wfw:commentRss><description>Well actually the code I am using is: &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Dim GMSRef&lt;br /&gt;GMSRef = "abc.xml"&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;which produces the original error about thisXDocument&lt;br /&gt;&lt;br /&gt;If I use&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Dim GMSRef As String&lt;br /&gt;GMSRef = "abc.xml"&lt;/pre&gt;&lt;br /&gt;or&lt;br /&gt;&lt;pre&gt;Dim GMSRef As String = "abc.xml" &lt;/pre&gt;&lt;br /&gt;it fails to even open the form:&lt;br /&gt;&lt;br /&gt;&lt;blockquote id="quote"&gt;&lt;font size="1" face="Verdana, Arial, Helvetica" id="quote"&gt;quote:&lt;hr height="1" noshade id="quote"&gt;&lt;br /&gt;InfoPath cannot open new blank form.&lt;br /&gt;InfoPath cannot open the selected form because of an error in the form's code.&lt;br /&gt;The following error occurred:&lt;br /&gt;&lt;br /&gt;Expected end of statement&lt;br /&gt;File:script.vbs&lt;br /&gt;Line:25&lt;br /&gt;DIM GMSRef as string = "abc.xml"&lt;br /&gt;or &lt;br /&gt;DIM GMSRef as string&lt;br /&gt;&lt;hr height="1" noshade id="quote"&gt;&lt;/font id="quote"&gt;&lt;/blockquote id="quote"&gt;&lt;br /&gt;</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13258.aspx</link><pubDate>Fri, 17 Jun 2005 09:50:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13258</guid><dc:creator>ScottAtRVC</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13258.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13258</wfw:commentRss><description>Hi.  Again just a sanity check.  Your code is - DIM GMSRef as string = "abc.xml"   Cheers. Scott.</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13257.aspx</link><pubDate>Fri, 17 Jun 2005 07:30:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13257</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13257.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13257</wfw:commentRss><description>I changed the value of GMSref to abc.xml&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;GMSRef = abc.xml&lt;br /&gt;'GMSRef = thisXDocument.DOM.selectSingleNode("my:myfields/my:field5").text&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The error message changed, only now instead of saying object required is 'ThisXDocument' it was now requiring  object "abc.xml"</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13256.aspx</link><pubDate>Fri, 17 Jun 2005 07:24:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13256</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13256.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13256</wfw:commentRss><description>Hello&lt;br /&gt;&lt;br /&gt;The field does exist and hopefully I am referencing it correctly. In looking at the datasource (main) I have a folder myfields, within it I have the field called field5 which is expecting a string - it has validation ensuring that the field is not left blank. &lt;br /&gt;&lt;br /&gt;I simply added a series of text boxes etc and accepted the default names. &lt;br /&gt;&lt;br /&gt;I can also confirm that myfields and field5 is all lowercase.&lt;br /&gt;&lt;br /&gt;Thanks</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13255.aspx</link><pubDate>Thu, 16 Jun 2005 23:06:53 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13255</guid><dc:creator>Shanthi Reddy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13255.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13255</wfw:commentRss><description>One other thing is does field5 node contain a value? Please makie sure that it does contain that. Also i would suggest setting some hardcoded value such as abc.xml to GMSRef and verify that the file does get saved. &lt;br /&gt;&lt;br /&gt;This will let us know for sure that its because the value of GMSRef is incorrect that the file is not getting saved. It could be either that it is null or it contains a character that is not suitable for a file name.&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;br /&gt;&lt;br /&gt;Shanthi&lt;br /&gt;InfoPathDev India</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13254.aspx</link><pubDate>Thu, 16 Jun 2005 14:28:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13254</guid><dc:creator>ScottAtRVC</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13254.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13254</wfw:commentRss><description>Hi.  &lt;br /&gt;&lt;br /&gt;Just as a sanity check does my:myfields/my:field5 exist? or is it myFields or Field5.  XPath is case sensitive.&lt;br /&gt;&lt;br /&gt;cheers. Scott.</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13253.aspx</link><pubDate>Thu, 16 Jun 2005 14:22:31 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13253</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13253.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13253</wfw:commentRss><description>Thanks for the response but it didn't make any difference. Any other ideas?</description></item><item><title>Re: OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/13252.aspx</link><pubDate>Thu, 16 Jun 2005 09:42:08 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13252</guid><dc:creator>ScottAtRVC</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13252.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13252</wfw:commentRss><description>Hi.  &lt;br /&gt;&lt;br /&gt;I believe the error is being caused due to your XPath command.&lt;br /&gt;The // will selects nodes in the document from the current node that match the selection no matter where they are.&lt;br /&gt;In addition you are fully qualifying the node you want.&lt;br /&gt;Therefore the node is not being located and thus calling the .text method raises an exception.&lt;br /&gt;&lt;br /&gt;Could you try changing your line 24 to;&lt;br /&gt;GMSRef = thisXDocument.DOM.selectSingleNode("my:myfields/my:field5").text&lt;br /&gt;Basically remove the //&lt;br /&gt;&lt;br /&gt;cheers. Scott.&lt;br /&gt;</description></item><item><title>OnSaveRequest function</title><link>https://www.infopathdev.com:443/forums/thread/12466.aspx</link><pubDate>Tue, 14 Jun 2005 07:47:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12466</guid><dc:creator>hudsucker</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12466.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12466</wfw:commentRss><description>Only just started dabbling with InfoPath. I am currently designing a form that needs to be saved to a specific location with a specific reference id as the file name which is to be taken from a field within the form. But alas, as you might have guessed, it does not work for me.&lt;br /&gt;&lt;br /&gt;I have followed steps outlined in the article Extending the Save Functionality in InfoPath 2003 &lt;br /&gt;&lt;br /&gt;&lt;a href='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extending_save.asp' target='_blank' title='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extending_save.asp'&lt;a target="_blank" href=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extending_save.asp&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extending_save.asp&lt;/a&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This document describes how to add script through Tools - Form Options &amp;gt; Open And Save &amp;gt; Save Behaviour &amp;gt; Save using custom code&lt;br /&gt;&lt;br /&gt;The code I have used is as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Sub XDocument_OnSaveRequest(eventObj)&lt;br /&gt;&lt;br /&gt;' Write the code to be run before saving here.&lt;br /&gt;&lt;br /&gt;Dim GMSRef&lt;br /&gt;&lt;b&gt;&lt;font color="red"&gt;GMSRef = thisXDocument.DOM.selectSingleNode("//my:myfields/my:field5").text&lt;/font id="red"&gt;&lt;/b&gt;&lt;br /&gt;If thisXDocument.IsNew = True or eventObj.IsSaveAs = False then&lt;br /&gt;	If eventObj.IsSaveAs = True then&lt;br /&gt;		thisXDocument.UI.SetSaveAsDialogLocation("f:\Windows Infrastructure\Inspection Form")&lt;br /&gt;		thisXDocument.UI.SetSaveAsDialogFileName(GMSRef)&lt;br /&gt;	End If&lt;br /&gt;	eventObj.IsCancelled = eventObj.PerformSaveOperation()&lt;br /&gt;	eventObj.ReturnStatus = true&lt;br /&gt;Else&lt;br /&gt;		thisXDocument.UI.Alert("The 'Save As' functionality is disabled for forms that are not new.")&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The error message is as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;blockquote id="quote"&gt;&lt;font size="1" face="Verdana, Arial, Helvetica" id="quote"&gt;quote:&lt;hr height="1" noshade id="quote"&gt;InfoPath cannot save the form.&lt;br /&gt;The OnSaveRequest function returned a value indicating that the save failed.&lt;br /&gt;The following error occurred.&lt;br /&gt;&lt;br /&gt;Object required: 'thisXDocument'&lt;br /&gt;File:script.vbs&lt;br /&gt;Line 24&lt;hr height="1" noshade id="quote"&gt;&lt;/font id="quote"&gt;&lt;/blockquote id="quote"&gt;&lt;br /&gt;&lt;br /&gt;Line 24 is highlighted red and bold.&lt;br /&gt;&lt;br /&gt;Any help would be gratefully recieved. I know I am doing something daft and it is most likely to do with the way I am using vb.&lt;br /&gt;&lt;br /&gt;Thanks</description></item></channel></rss>