4 Replies Latest reply on Oct 12, 2012 10:56 AM by EvaKiss

    Timestamp

    EvaKiss

      Title

      Timestamp

      Post

           Hi All,

           My problem is the following: I have a huge table which content will be modified continuously. I would like to create another table which would contain a timestamp if any modification happens in the original table, cell by cell.

           So the two table would be totally the same but one included the information, the another the timestamp of any modification of it. I would like to do that the second table creates the timestamps automatically. Hope it is clear. Anyone can help me in creating this "timestamp" table?

           Thanks

            

            

        • 1. Re: Timestamp
          philmodjunk

               You can use script triggers on each field to perform a script that logs the current timestamp in the corresponding record in the table of timestamp fields. Use a primary key in the current table to match to a foreign key in the timestamp table. Enable "allow creation of records via this relationship" so that the first time such a trigger is tripped, it automatically creates the matching record in the TimeStamp table.

               YourTable::__pkYourTableID = ModLog::_fkYourTableID

               The script can be:

               Set Field By Name [ Get ( ScriptParameter ) ; Get ( CurrentTimeStamp ) ]

               This allows you to use one script for each field, use this expression as the script parameter:

               GetFieldName ( YourTable::FieldName )  // but use an actual table and field name from your solution.

               GetFieldName ensures that this continues to work even if you rename a field, table or table occurrence.

          • 2. Re: Timestamp
            philmodjunk

                 Hmmm, Typed too fast there, we need to modify that slightly:

                 Set Field By Name [ "ModLog::" & Get ( ScriptParameter ) ; Get ( CurrentTimeStamp ) ]

                 and the parameter expression should be:

                 Let ( T = GetFieldName ( YourTable::FieldName ) ; Left ( T ; Position ( T ; ":" ; 1 ; 1 ) - 1 ) )

                 This assumes exactly matching field names in ModLog and your table.

            • 3. Re: Timestamp
              philmodjunk

                   Geeze, the caffiene deficit in my brain must be huge. I still don't have the correct parameter expression! blush

                   Let ( T = GetFieldName ( YourTable::FieldName ) ; Right ( T ; Length ( T ) - Position ( T ; ":" ; -1 ; 1 ) - 1  ) )

                   Note: tested this one in the DataViewer to be sure that it works.

                    

              • 4. Re: Timestamp
                EvaKiss

                     Thanks a lot! I will try it, it was a huge help!

                     Eva