onRecordUpdate Table Event - Old Values?

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.

greg.

Hi Bob,

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.

Thanks Greg & Robert!

I’ll tinker around and see if I can come up with a solution in 4.x (although 5 will be AWESOME - it will require re-working TONS of methods)…

Hi Bob,

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.

I saw a solution of Ayton, doing that already (in Servoy 3.5)
I think they used the databaseManager.getChangedRecordData() for that, not sure…

they will attend ServoyCAMP with 4 persons, so we can ask them, in the show & tell session at thursday evening ;-)

Ah crap! I overlooked that function! :oops:

Awesome! I’ll give it a try…

Ummmmm… YES!! Thanks, Harjo. I was doing a bunch of crap that didn’t need to be done.

As usual, Servoy already had it in there! Awesome!

Cool! :D