How to Get Old %Persistent Object Properties in %OnBeforeSave?
I am trying to make Caché perform certain actions depending on whether a particular property of the object was changed using triggers.
For example, say I have this class:
Class Dummy.Class Extends %Persistent {
Property Name As %String;
Property Visible As %Boolean;
Trigger OnUpdate [ Event = UPDATE/DELETE, Time = BEFORE ] {
if ({Published*O} = 0) && ({Published*N} = 1) {
do ..CertainAction({ID})
}
}
ClassMethod %OnBeforeSave(insert As %Boolean) As %Status [ Private, ServerOnly = 1 ] {
// ... ?
}
ClassMethod CertainAction(objId) {
set ^test = "Object ID=" _ objId _ " has just become visible!"
}
}
I was able to make CertainAction
executed on any SQL update, but it doesn't work when object is saved from COS, via .%Save()
. However, %OnBeforeSave
works instead, but I have no idea how can I access previously set properties there. I tried opening an object there in-place, but the properties turned to be all new instead of old ones.
Thank you for any help.