<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Does File still save, if there is an error in an BeforeSave triggered rule? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036632#M22346</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13604528"&gt;@d_eckel&lt;/a&gt;.&amp;nbsp; In addition to what Michael said, keep in mind the rule running order.&amp;nbsp; If your other rule is already listed under the before save event, you would want his rule to be listed below that other rule under that event, so that it will be the second (or next) one to run when that event happens, after your regular rule.&amp;nbsp; When that event happens, it will run the rules listed under that event in the order they are listed in the Event Triggers dialog.&amp;nbsp; Not sure which one would run first if one rule is on the All Documents tab, and another rule is on the This Document tab, under the same event though.&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; Actually, you might want that 'checker' rule to be under the 'after save' event.&amp;nbsp; That way, if it does not show anything, it did not save.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 15:26:31 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2023-06-15T15:26:31Z</dc:date>
    <item>
      <title>Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036006#M22342</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a fast question.We have some issues with saving files in the last couple of weeks and I just want to make sure, none of the iLogic Rules is the problem.&lt;/P&gt;&lt;P&gt;Does a File (part, assembly, drawing) still save, if there is an error in an BeforeSave triggered rule?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 11:40:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036006#M22342</guid>
      <dc:creator>d_eckel</dc:creator>
      <dc:date>2023-06-15T11:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036227#M22343</link>
      <description>&lt;P&gt;It may not save.&lt;/P&gt;&lt;P&gt;The error could stop and error out before it get to save.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 13:11:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036227#M22343</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-06-15T13:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036563#M22344</link>
      <description>&lt;P&gt;In my opinion the document is NOT saved when before save rule raises exception.&lt;/P&gt;&lt;P&gt;You can easily test this with this simple rule.&lt;/P&gt;&lt;P&gt;Add this rule "before save" and look what happens&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Logger.Debug(ThisDoc.Document.FileSaveCounter)
If MsgBox("Raise exception?", MsgBoxStyle.YesNo + MsgBoxStyle.Question) = MsgBoxResult.Yes Then
	Throw New ApplicationException("This is expected exception")
End If&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 14:58:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036563#M22344</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2023-06-15T14:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036616#M22345</link>
      <description>&lt;P&gt;it may not save but you can add a Try Catch between your rules....that way it will not stop the next action.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Try 
  'INSERT YOUR CODE HERE
Catch
  'INSERT THE WAY YOU WANT TO BE NOTIFIED OF THE ERROR..IF NEEDED
End Try&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;A href="https://mcmcad.com" target="_blank"&gt;&lt;BR /&gt;&lt;IMG src="https://mcmcad.com/SignatureEmail/MCMCAD_T_900x600.png" border="0" alt="Logo MCMCAD" /&gt;&lt;BR /&gt;&lt;/A&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:45:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036616#M22345</guid>
      <dc:creator>SebastienOuellet</dc:creator>
      <dc:date>2023-06-15T16:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036632#M22346</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13604528"&gt;@d_eckel&lt;/a&gt;.&amp;nbsp; In addition to what Michael said, keep in mind the rule running order.&amp;nbsp; If your other rule is already listed under the before save event, you would want his rule to be listed below that other rule under that event, so that it will be the second (or next) one to run when that event happens, after your regular rule.&amp;nbsp; When that event happens, it will run the rules listed under that event in the order they are listed in the Event Triggers dialog.&amp;nbsp; Not sure which one would run first if one rule is on the All Documents tab, and another rule is on the This Document tab, under the same event though.&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; Actually, you might want that 'checker' rule to be under the 'after save' event.&amp;nbsp; That way, if it does not show anything, it did not save.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:26:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036632#M22346</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-06-15T15:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036929#M22347</link>
      <description>&lt;P&gt;The fun of using event trigger.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 17:11:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12036929#M22347</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-06-15T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12037134#M22348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13604528"&gt;@d_eckel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could add a save line to a Finally statement as shown here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep in mind, a Finally statement always runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example a parameter that does not exist called foo is being set, so an error is encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Finally statement checks to see if the save counter has incremented, and if it has not then it saves the document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;main&lt;/SPAN&gt;

	&lt;SPAN&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;FileSaveCounter&lt;/SPAN&gt;, , &lt;SPAN&gt;"iLogic"&lt;/SPAN&gt;)

	&lt;SPAN&gt;SAVEcount&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;FileSaveCounter&lt;/SPAN&gt;

	&lt;SPAN&gt;Try&lt;/SPAN&gt;
		&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;My_iLogic_Code&lt;/SPAN&gt;
	&lt;SPAN&gt;Catch&lt;/SPAN&gt;
		&lt;SPAN&gt;Logger&lt;/SPAN&gt;.&lt;SPAN&gt;Info&lt;/SPAN&gt;(&lt;SPAN&gt;"there was an error"&lt;/SPAN&gt;)
	&lt;SPAN&gt;Finally&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;SAVEcount&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;FileSaveCounter&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Save&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Try&lt;/SPAN&gt;

	&lt;SPAN&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;.&lt;SPAN&gt;FileSaveCounter&lt;/SPAN&gt;, , &lt;SPAN&gt;"iLogic"&lt;/SPAN&gt;)

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;

&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;My_iLogic_Code&lt;/SPAN&gt;
	
	&lt;SPAN&gt;'here is all of your rule code:&lt;/SPAN&gt;

	&lt;SPAN&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN&gt;"foo"&lt;/SPAN&gt;) = &lt;SPAN&gt;"foo-who"&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 18:42:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12037134#M22348</guid>
      <dc:creator>Curtis_Waguespack</dc:creator>
      <dc:date>2023-06-15T18:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12038172#M22349</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/105031"&gt;@Curtis_Waguespack&lt;/a&gt;&amp;nbsp;your code doesn't work. Avoid to call Document.Save from OnSave event handler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim fileSaveCounter = ThisDoc.Document.FileSaveCounter

Try
	Logger.Debug(fileSaveCounter)
	Throw New ApplicationException("Expected exception")
Catch ex As Exception
	Logger.Error(ex.Message)
Finally
	If fileSaveCounter = ThisDoc.Document.FileSaveCounter Then
		ThisDoc.Save()
	End If
End Try&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It ends with another unhandled exception in better case. In the worst case you get StackOverflowException when someone doesn't handle this recursive call.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Problems encountered while saving the document.
	Access is denied. 
	The database in  could not be saved&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 06:45:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12038172#M22349</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2023-06-16T06:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Does File still save, if there is an error in an BeforeSave triggered rule?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12038618#M22350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/105031"&gt;@Curtis_Waguespack&lt;/a&gt;&amp;nbsp;your code doesn't work. Avoid to call Document.Save from OnSave event handler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oooops! You're exactly right, a save call will not work with the Before Save trigger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I forgot to test this with the trigger when posting and didn't catch that the file can not be saved during that event (because the file is already being saved, thus the database conflict).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for the confusion, and thanks for catching this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 10:31:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/does-file-still-save-if-there-is-an-error-in-an-beforesave/m-p/12038618#M22350</guid>
      <dc:creator>Curtis_Waguespack</dc:creator>
      <dc:date>2023-06-16T10:31:56Z</dc:date>
    </item>
  </channel>
</rss>

