5 Replies Latest reply on Dec 9, 2011 11:47 AM by Immigranta

    Tracking changes on a file level...

    Immigranta

      Title

      Tracking changes on a file level...

      Post

      Hi guys,

       

      I have created a field that shows me what changes have been made to particular fields.

       

      I was wondering though how to show not only what change is made but how the field looked like before changing.

      i use Get ( ActiveFieldName ) for the field and Get ( ActiveFieldContents ) for data in the field but i am not sure what to use to capture what the data looked like before changing.

       

      Thanks for help.

        • 1. Re: Tracking changes on a file level...
          philmodjunk

          It's possible to use script triggers to build a list of original values from fields and the names of the fields in global variables. Then, an OnCommitRecord trigger can run a script that uses this data to log all prior values and the field names in a related table and then clears the global variables. The record shows the current value so reviewing this log lets you roll back change by change by showing you the prior values of any field that was changed. It's even possible to set up a system that uses a script so apply the changes from such a "change log" back into the modified fields to let you "undo" record commit by record commit all the way back to the record's original values when first committed.

          Such a system could also be used to create a more intelligent "synchronize" system when multiple copies of a database have to be merged back into a single unified copy.

          I'd use a global variable $$OldValue in an OnObjectEnter script to capture the original value, then use OnObjectSave to append the old value, active field name and active field table name to a pair of global variables using the list function to do so:

          Set Variable [$$FieldList ; value: List ( $$FieldList ; Get ( activeFieldTableName ) & "::" & get ( activeFieldName) ]
          Set Variable [$$ValueList ; valeu: List ( $$ValueList ; $$OldValue ]

          • 2. Re: Tracking changes on a file level...
            Immigranta
            Hi Phil,
             
            Thanks for imput. Capturing information of the field before is changed with a global variable($$OldValue) seem a good way. However, I would like to imput that $$OldValue into a field and to create a list with all old values. I thoutht i could use this character ¶.
            This is my thought but does not seems to work exactly the way i thought.
             
            Set Variable [$$OldValue ; value: field_name ]
            Set Field [field_name; Quote("- " & $$OldValue &  "¶" & $$OldValue)
            With this script it only updates the value to the new one but does not preseve the old ones.
             
            What do you think?
             
            Thanks
            • 3. Re: Tracking changes on a file level...
              mgores

              I think you missed that the $$OldValue needs to be a separate script triggered OnObjectEnter into the field so that it captures the contents before they are modified.

              Your script looks like you are setting the variable and placing it into another field in one step and doing that after the field contents have been modified.

              • 4. Re: Tracking changes on a file level...
                philmodjunk

                And List ( $$ValueList ; $$OldValue ) appends the contents of $$OldValue to the end of any data already present in $$ValueList, just like using the ¶ character, but with less need for special handling when this is the first such value to append to $$ValueList.

                • 5. Re: Tracking changes on a file level...
                  Immigranta

                  Thanks guys, it worked fine the way i wanted with your help.

                  I set a script trigger on the field and pulled the value with a $$OldValue.

                  Then i used that value with the new value and some other field i needed and set to a field with a calculation all that through a script that is triggered on a objectsave.