6 Replies Latest reply on Oct 30, 2015 6:59 AM by aetherington

    Detect when any field has changed

    aetherington

      Good afternoon.

       

      Once again asking advise from the great community!

       

      We have a lot of apprentice workers, and unfortunately, they make mistakes.  What we have been working on is traceability for pretty much any changes to a log.  Now one method I can think of is have every field use a script trigger that then records who and what was changed in the field.  This seems very messy and if we have 50 odd fields, Not viable.

       

      I thought there might be a way to use the layout on commit trigger, But this brought me here.   I could not find a way to detect exactly what fields had changed, only that something had been committed.

       

      If anyone knows of a great way to do this I am all ears.

       

      Thank you!

      -Ash

        • 1. Re: Detect when any field has changed
          bigtom

          on record load set global variables for each of your fields. On commit loop through the fields and verify if the global variable is equal to the comitted value. Script away from there on how you want to track it.  The results might stay in a log table.

          • 2. Re: Detect when any field has changed
            rgordon

            On Entry script trigger that stores a variable with the name of the field ($$field = Get(ActiveFieldName)) and the contents of the field ($$content1=Get(ActiveFieldcontents))

             

            On Exit script trigger that compares the content of the field ($$content2) with ($$content1).  If the contents are different the  script creates an entry in the log noting the change.

            • 3. Re: Detect when any field has changed
              jbrown

              There is a function, Get(ModifiedFields) ,that can detect which fields are being modified in the open, current record. I tested this out just now. You need to make sure to open the record.

              Then on the record commit script trigger, set another field to Get(modifiedFields). It actually works nicely.

               

              Again:

              1. Open record.

              2. Let users modifiy anything.

              3. Set a script trigger on the layout: onRecordCommit to set another field to Get(modifiedFields).

               

              Try it out. I think it could work in this setting.

               

              EDIT: this would certainly tell you which fields were modified, but would not tell you what the changes were. So I guess it might not work in this case, but it is still cool to try out this function.

              1 of 1 people found this helpful
              • 4. Re: Detect when any field has changed
                bigtom

                rgordon wrote:

                 

                On Entry script trigger that stores a variable with the name of the field ($$field = Get(ActiveFieldName)) and the contents of the field ($$content1=Get(ActiveFieldcontents))

                 

                On Exit script trigger that compares the content of the field ($$content2) with ($$content1).  If the contents are different the  script creates an entry in the log noting the change.

                Pretty much the many triggers thing the OP wanted to avoid, but it is an option.

                • 5. Re: Detect when any field has changed
                  siplus

                  prevention beats cure.

                   

                  Edit data in globals, do all your checks before retransferring their content to actual fields, no need for a log file that in a good, but not perfect world, will have 2000 legit entries and 3 bad to browse through, per field.

                  • 6. Re: Detect when any field has changed
                    aetherington

                    Exactally what I was looking for, I can work with this.

                     

                    I forgot to mark my OP as a question but Thank you very much for the answer, And to every one else for the comments