1 Reply Latest reply on Dec 14, 2011 8:15 AM by philmodjunk

    modification log

    JoshPoplawski

      Title

      modification log

      Post

      Ok, I've got a script that is triggered OnObjectModify that inserts

      Get ( AccountName )  &  " ("  & $$username   &  ") "  &  Get ( CurrentTimeStamp )  &  " "  & ¶ 

      into a "log" field without selecting the entire contents.

       

      This is to create a running log for each record of who and when it was last modified. Hoever i'd also like to record what was modified as well. their is no Get(lastModification) as far as i can find.

      Anybody have any ideas?

        • 1. Re: modification log
          philmodjunk

          I'D use a separate related table to log such results.

          You can use the OnObjectEnter Trigger to save the original value of each such field where you want to log the modifications. You can put the reference to the field in the format TableOccurrence::FieldName in the trigger's script parameter and then use:

          Set Variable [$$OldValue ; value: Get ( ScriptParameter ) ]

          This allows you to use the same script with every field and works with all field formats.

          You can then use the OnObjectSave Trigger (onObjectModify will fire with every keystroke in the field and you ususually do not want that to happen) to run a script that appends the $$Old value to a list in one global variable and uses Get ( ActiveTableName ) and Get ( ActiveFieldName ) to append the tableoccurrence and field names to a second variable.

          A script step like this can append a value to the end of an existing list in a Global variable:

          Set Variable [$$FieldList ; value: List ( $$FieldList ; Get ( ActiveTableName ) & "::" & Get ( ActiveFieldName ) ) ]

          Then use OnRecordCommit to run a script that logs the Record's Serial ID, the fields modified and their previous values. Other fields in this table can auto-enter the Acccount name, Creation Time stamp and user name so you do not have to specfically script for each.

          A script can then use these logged fields and their values to undo changes to the record one change at a time all the way back to the very first logged changes in this table.