I’ve used the onRecordInsert and onRecordDelete table events in the past - but I’m interested in using the onRecordUpdate in order to “capture” the edited values.
For various reasons, I’m not using the built-in Servoy security - so using “tracking” isn’t an option.
Ideally, I’d like to be able to use onRecordUpdate to get the old value/new values and do some custom logging…
However, I don’t think that’s possible using the table event??
Perhaps not super neat…but you could fire rawSQL in the update event. The values in the database haven’t changed yet.
In general, it would be super cool if “record” objects knew about their original state, however. ie, had a “record.orig()” method that returned a non-mutable version of the record as it was last loaded from the db.
I think you need to use Servoy 5 for what you want. A JSRecord (passed by to the onBeforeUpdate event) has now a function named getChangedData() which returns a dataset with the changes (somewhat what Greg is talking about). There is one downside here though, these are PRE-update triggers and the back-end database might refuse your data and not store the changes you already logged.
In Servoy 5 you have POST-Insert/Update/Delete triggers but in my brief examination of this functionality the AfterUpdate event doesn’t give the old values.
I will file a feature request for this.
bobcusick:
(although 5 will be AWESOME - it will require re-working TONS of methods)…
Only the ones connection to any events…and even then the Problems View will help you out with a Quick Fix (well…for marking it).
All in all it’s not too much work if you don’t have to hunt for it.
And yes. 5 IS awsome. It VERY much deserves the whole version point jump.