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 ]
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?
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.
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.
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.