1 2 Previous Next 17 Replies Latest reply on Aug 27, 2012 1:27 PM by darylhansen

    Ray's UltraLog Mod

    darylhansen

      I was wondering if anyone has figured out how to modify Ray's UltraLog Custom Function to not track field changes when the field was previosuly empty. I have no need to know what a field is, if it was previosuly empty, because it is a given. I have beat my head over this thing for hours and can;t seem to figure it out. I thought it would be simple.

       

      Thanks.

       

      ____________________________________________________________

       

      // SYNTAX: UltraLog ( LogField; ModTime; FieldsToLog )

      // ORIGIN: http://www.nightwing.com.au/FileMaker

      // NOTES: Transactional (IWP Compatible) Audit Log Function.

      // VERSION: 1.0v4

      // © 2009 Ray Cologon, NightWing Enterprises, Melbourne, Australia

       

       

      Case(Prefs::LogSetting= "On" and ValueCount(FieldsToLog) and not $ClearLogPermit;

      Let([

      Fnm = GetValue(FieldsToLog; 1);

      Pref = Position(LogField; " " & Fnm & " "; 1; 1);

      Pst = Position(LogField; " -» "; Pref; 1) + 4;

      Pnd = Position(LogField & ¶; ¶; Pref; 1);

      Pval = If(Pref; Middle(LogField; Pst; Pnd - Pst); "[---]");

      Fval = GetField(Fnm);

      Sval = Substitute(Fval; ¶; "‡");

      Nval = If(Length(Fval); Sval; "[null]");

      vInit = Pref = 0 and IsEmpty(Fval);

      Prep = Exact($ClearLogPermit; "0");

      MTm = Get(CurrentHostTimeStamp)];

      If(not Exact(Pval; Nval) and not vInit;

      TextStyleAdd(TextColor(

      GetAsDate(MTm) & " " & GetAsTime(MTm) & " " &

      If(Prep; "[Log Prep]"; Get(AccountName)) & " " &

      Fnm & " " & Pval & " -» " & Nval & ¶; Prep*11776947); Prep*Italic)) &

      UltraLog(LogField; ModTime; RightValues(FieldsToLog; ValueCount(FieldsToLog) - 1))

      );

      LogField

      )

        • 1. Re: Ray's UltraLog Mod
          Malcolm

          A change is a change is a change. If the field was empty prior to editing and it has a value after editing doesn't that warrant a line of text in the log?

           

          Even if you answer no, is it worth wasting hours just to have your way?

           

          malcolm

          • 2. Re: Ray's UltraLog Mod
            LyndsayHowarth

            I agree with Malcolm,

             

            What happens in your scenario if someone empties the field?

             

            Empty is an important state for many reasons and I would never leave it out of a log.

             

            If I were modifying the CF at all, I would be making it log the word EMPTY >> NewValue.

             

            - Lyndsay

            • 3. Re: Ray's UltraLog Mod
              darylhansen

              If someone changed the field to emtpy, then it would track, because the Previous value was not empty.  I don't want it to track only when the PREVIOUS value as empty, which is 90% of the log and I don't need that uneccessary bloat in my solution. So, yes, for me it is worth it.

               

              Daryl

              • 4. Re: Ray's UltraLog Mod
                Malcolm

                I don't want it to track only when the PREVIOUS value as empty, which is 90% of the log and I don't need that uneccessary bloat in my solution. So, yes, for me it is worth it.

                 

                Use the method which pushes the change log into records in a separate table. You will still get records that log the change from empty to . However, you can run an onOpen or OnClose script that deletes these records from the log.

                 

                Malcolm

                • 5. Re: Ray's UltraLog Mod
                  RubenVanDenBoogaard

                  Hi Daryl,

                   

                  Take a look at Ray's sample file. There is a script to set the initial values of the fields.

                   

                  Hope that helps,

                   

                  Best regards,

                   

                  Ruben van den Boogaard

                  Infomatics Software

                  ruben@infomatics.nl

                  • 6. Re: Ray's UltraLog Mod
                    darylhansen

                    I am not seeing it.

                    • 7. Re: Ray's UltraLog Mod
                      pthomas

                      darylhansen wrote:

                       

                      If someone changed the field to emtpy, then it would track, because the Previous value was not empty.  I don't want it to track only when the PREVIOUS value as empty, which is 90% of the log and I don't need that uneccessary bloat in my solution. So, yes, for me it is worth it.

                       

                      Daryl

                       

                      Are you not concerned about the following scenario:

                       

                      Field is set from Empty to Value X

                      Field is set from Value X to Empty

                      Field is set from Empty to Value Y

                       

                      Would you not want to know who made the 3rd change and when it happened etc?

                       

                      Would it not be confusing to look at the log and expect the field to be empty as that was the last action logged but then look at the field and see Value Y?

                       

                      Based on your requirement you are saying that in this scenario you don't want to log the change as the previous value was Empty?

                       

                      It can also be very useful to know WHEN a field is first populated with data as this can explain why a record wasn't included in a report/data extract run on a certain date etc...

                      • 8. Re: Ray's UltraLog Mod
                        darylhansen

                        Hi Paul,

                         

                        No, I wouldn't, because the third change would be reflected in the current state of the database.  We are not using the log for the same reasons most people are.  However, I am starting ti think that the performance impact is minimal for the way that it currently is. But is sure would be nice to have to option to not track the changes from empty.

                         

                        Daryl

                        • 9. Re: Ray's UltraLog Mod
                          pthomas

                          Fair enough!

                           

                          I guess most people use a log to track not only what has changed but when it was changed and who made the change.

                           

                          If that is not your requirement then I can understand why you wouldn't want the extra "bloat" of tracking the changes from empty!

                          • 10. Re: Ray's UltraLog Mod
                            darylhansen

                            I must admit, Ray's Ultra Log is super convenient.  I suppose I could simply automate (via a Server Side Script) the movement of the log entries into separate records that are located in a separate file.  That way, I wouldn't have to worry about bloating.

                             

                            Daryl

                            • 11. Re: Ray's UltraLog Mod
                              darylhansen

                              Ah, I thought of something.  What if I evaluate the log and if the field was previously empty on all fields only, then the log will not auto enter.  But as soon as any one of the previous field values was not empty, the log will then start to track all changes normally.  There must be a way to do this.

                               

                              Perhaps I could test of the number of times this appears

                              [---]

                              and if that matches the same number of carriage returns, then I can auto delete the log?

                              • 12. Re: Ray's UltraLog Mod
                                user14135

                                I have not tested this, however I believe you can change the first line of the IF test that occurs after the LET statement:

                                If(not Exact(Pval; Nval) and not vInit;

                                 

                                to this:

                                If(not Exact(Pval; Nval) and not IsEmpty(Fval);

                                 

                                and get what you initially stated you wanted - every time the value of the field is empty, the change is not logged.

                                 

                                 

                                However, let's look at things a little more closely, because I'm pretty sure that as written the function is meant to avoid logging the first change in a field. The IF test excerpted above is checking that there's a difference between the Pval and Nval variables. Nval is either the value of the field (stored in Fval) with newlines substituted or the string "[null]" and Pval is the first value found in the log file associated with that field name. The IF test also evaluates whether or not Pref = 0 (Pref looks for the field name in the log field, it will be zero if the field has not already been logged) AND there's a value in the field (IsEmpty(Fval)).

                                 

                                So let's write this out a bit more verbosely to aid in clarity:

                                IF theFieldToLog has not been previously entered in the log and it has no value, THEN vInit will be 1 ELSE vInit will be 0 (zero)

                                IF the current value of theFieldToLog does NOT exactly match the first value stored in the log AND vInit = 0 THEN add the log entry

                                 

                                Remember, vInit will be zero when there's already a log entry for the field in question and the field currently has a value.

                                 

                                So, as far as I can tell, the standard behaviour is to _NOT_ log the value for a field if it is empty until it has already been added to the log.

                                • 13. Re: Ray's UltraLog Mod
                                  darylhansen

                                  OMG, that almost works! It's just backwards.  What that mode does is it doesnt track changes when the new field value is empty, instead it tracks when the previous value was empty.  Just need it the other way.  So close!

                                  • 14. Re: Ray's UltraLog Mod
                                    user14135

                                    OK then, just change it to

                                    If(not Exact(Pval; Nval) and IsEmpty(Fval);

                                     

                                    That should do the trick.

                                    1 2 Previous Next