The issue is best described by 123 in this 2009 thread:
http://cocoontech.co...eleted-objects/
Basically, when you delete an object, any remaining timers will eventually execute. If these timers point to the deleted object, you'll get an error and the vbscript interpreter will halt. Typically, most of us have used something similar to the line below in these situations:
Note that "on error resume next:" is appended to the timer.
However, this is sloppy and can mask errors. Building upon 123's work, I have figured out that the code below when placed in a "ChileDeleted" (aka "ClassChildDeleted") event method will always remove a persistent timer.
The attached image shows how I used this method in a new Weather module. After the user creates a home object of type "Weather" and clicks update, and update timer will trigger every 1800 seconds. The code shown will remove this update timer whenever the home object is deleted, assuming its children are still present.
Thus, if you want to use this work around on an object with no children, simply create some hidden child object whenever the object is created. To do this: use a class constructor method and add code similar to this to create an object of type "Object." Note that I also prevent the end user from deleting the object and hide the object.
Note that the flag definitions are found in this thread: http://cocoontech.co...better-drivers/
http://cocoontech.co...eleted-objects/
Basically, when you delete an object, any remaining timers will eventually execute. If these timers point to the deleted object, you'll get an error and the vbscript interpreter will halt. Typically, most of us have used something similar to the line below in these situations:
Code:
system.addTimer this.UpdateInterval,"on error resume next:this.Update = true",1,"Weather_" & this.ObjectID
Note that "on error resume next:" is appended to the timer.
However, this is sloppy and can mask errors. Building upon 123's work, I have figured out that the code below when placed in a "ChileDeleted" (aka "ClassChildDeleted") event method will always remove a persistent timer.
Code:
if this.Name = "" then
system.removeTimer "Weather_" & this.ObjectID
end if
The attached image shows how I used this method in a new Weather module. After the user creates a home object of type "Weather" and clicks update, and update timer will trigger every 1800 seconds. The code shown will remove this update timer whenever the home object is deleted, assuming its children are still present.
Thus, if you want to use this work around on an object with no children, simply create some hidden child object whenever the object is created. To do this: use a class constructor method and add code similar to this to create an object of type "Object." Note that I also prevent the end user from deleting the object and hide the object.
Code:
' Create an object of type "Object"
set oTmp = this.CreateObject("sys://Schema/System/Object","Foo")
' Hide the object (e.g. 0x2 = 2)
' Set NODELETE for user (e.g. 0x20000 = 131072, but system can still delete)
oTmp.SetValue "Flags", 131074
set oTmp = nothing
Note that the flag definitions are found in this thread: http://cocoontech.co...better-drivers/