user12837

Logging Script Trigger

Discussion created by user12837 on Sep 23, 2012
Latest reply on Sep 24, 2012 by nsabel

I run FM 11.

 

I use onObjectSave to write an entry to a log table of the form

 

LogID

TableName

FieldName

OldValue

NewValue

User

Date

 

but I don't know how to capture OldValue.

 

The approach which ought to work is to use a separate onObjectEnter trigger to write the current value of the selected field to a global field. But onObjectEnter does not fire when one selects a field within a portal (it fires only when a different portal row is selected).

 

I could use onRecordLoad to copy the entire record to mirror table consisting of globals, and get OldValue from this mirror table whenever the user changes the corresponding field in the real table. But I'm dealing with a table with hundreds of columns. Seems like too much work.

 

The number of columns also makes UltraLog infeasible. The list of fields in the calculation UltraLog( LogData; ModStamp; "TheText¶TheText[2]¶TheNumber¶TheDate¶TheTime") would be the length of a short story -- much too tricky to maintain.

 

What I need is either a beforeModify trigger, or the DELETED and INSERTED tables provided by Transact-SQL (but I don't want to use ESS in this case).

 

What's the efficient FM way to do this?

 

Thanks,

 

Tom

Outcomes