ILogic Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) after SaveAs

ILogic Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) after SaveAs

gcarvac
Enthusiast Enthusiast
211 Views
2 Replies
Message 1 of 3

ILogic Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) after SaveAs

gcarvac
Enthusiast
Enthusiast

I have an external ILogic rule:

Dim PartNumber As String = iProperties.Value("Project", "Part Number")
Dim doc = ThisDoc.Document
Parameter("GSS_SortCode") = PartNumber.Substring(0,3)
doc.Save

When I SaveAs a document, I get 

gcarvac_0-1721351079989.png

gcarvac_1-1721351089943.png

 

My guess is that is is because ThisDoc refers to the document where I clicked SaveAs, and the ILogic rule is triggered to run after save and therefore on the new document?

0 Likes
212 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @gcarvac.  That is a tough one to diagnose with only that information to go by.  I do know that it is always a bad idea to include instructions to save within an iLogic rule that is triggered to run by either the 'Before Save Document' or 'After Save Document' events in the Event Triggers dialog.  That can create an endless loop in some situations, and can lead to errors in other situations.  No need to include instructions to save, when the document is already in the process of being saved when the code runs.  But another small detail seems odd here.  The error message says the error happened at Line 3, but Line 3 in the code sample above is this:

Parameter("GSS_SortCode") = PartNumber.Substring(0,3)

..., because in the 'More Info' tab, where it is showing more details, it indicates that the error is happening when it is trying to Save.  Again, that could be because it is trying to save, while already saving.  I have seen that before multiple times.  But adding a SaveAs in the mix complicates things even further, so I'm not sure.  Also, just as added robustness against errors, you should probably check the value of 'PartNumber', to make sure it is not 'empty', before attempting to extract a sub string from within it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

gcarvac
Enthusiast
Enthusiast

Thanks for your help@WCrihfield . You are correct, I should check to see if PartNumber isn't empty. I hadn't thought of the possibility of the loop with the save, so I'll investigate not having that line.

0 Likes