Logging edits to a record

  • 1
  • 1
  • Question
  • Updated 1 year ago
  • Answered

Is it possible to set up a multi line text field that can log every edit made to a record with the field that was touched, user who did it and a date stamp?

Photo of Krishna

Krishna

  • 10 Points

Posted 5 years ago

  • 1
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,184 Points 20k badge 2x thumb
My original example used a text multiline field with logging turned on so the user and timestamping was created by QuickBase automatically - the script just gather the old and new values of those fields that changed and stuffed them into the logging field. To log just the last n changes or changes over the last 7 days you would have to use a text multiline field without logging turned on and (1) perform all the  user and timestamping yourself in addition to (2) removing "old" changes that become stale and (3) adding "new" changes. It is just more script to write to suit the specific needs of your logging strategy. If you need help contact me off-world using the info in my profile.
Photo of Jonny

Jonny

  • 0 Points
Thank you!
Photo of Jonny

Jonny

  • 0 Points
Dan, I`ve solved this problem.
1)I created a new table /Tracking/, connect this table with /Projects/.
Each Project has many Tracking. Now /Project/ consists: 'Track'-report link and 'Add Track'. /Tracking/ consists: Related project and Text(lookup) Project-Log.
2)Next step, I went to "Change the properties" field [Log]  and simply changed "Display when this is used for:" edit. My aim was: do not see the tracking in project in view.
3)I changed the field [Tracks] to 'Display just link' and open in a new window.
Now, everything work ideal: a little link on the button of each project called [Tracking], plus now I have options which project I`d like to track!
Thank you and have a wonderful day!
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,184 Points 20k badge 2x thumb
I have already started to celebrate your solution! Happy Weekend!
Photo of Jonny

Jonny

  • 0 Points
Good joke! :smile: )) You too have a nice weekend!
And thanks for the great help in the community!
Photo of Brian

Brian

  • 0 Points
Hi Dan, I successfully set this up in my table.  The only issue I have is that when it logs the changes, the names of the fields are logged as they appear in my form; that is, the title of the field in my log is the form alias.  This is problematic for me as we have a matrix of fields set up, and the aliases are all empty text.  Is there a way to have the log use the actual field names instead of the form alias'?

Hope that was a clear explanation of my problem.  And as a side note, Thanks for all your continued contributions to the community.  You have solved so many of my QB issues with your posts.  Thank you.
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Dan, I am employing your solution ,but I have a question for you regarding the logging of check boxes. Below is an example of how the code is logging currently. 
Can I have it say "Was = Off; now = On" ?
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
[NOV-06-17  8:39 AM  XXX] ROM Confirmed Completion was =1; now =on
Ready To Invoice - Notify AR was =0; now =on
In AR Review was =0; now =on
Rejected By AR was =0; now =on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Dan I appreciate your help!
On last thing.
I would like for this to only say "On" or Off if it's a checkbox. The code is also logging text and number fields.
(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,094 Points 20k badge 2x thumb
Try this (changed lines in bold):

$("#_fid_342").attr("readonly", "readonly");
var label, oldValue, newValue, log, type;
$("#_fid_243, #_fid_235, #_fid_237, #_fid_251, #_fid_239, #_fid_241, #_fid_259, #_fid_132").on("change", function() {
  log = [];
  _.each([243, 235, 147, 237, 251, 239, 259, 132], function(fid) {
    oldValue = $("[name=_fid_oval_" + fid + "]").val();
    newValue = $("#_fid_" + fid).val();
    type = $("#_fid_" + fid).attr("type");
    if (oldValue != newValue) {
      label = $("label[for=_fid_" + fid + "]").text();
      if (type == "checkbox") {
        log.push(label + " was =" + (oldValue ? "on" : "off") + "; now =" + newValue);
     } else {
        log.push(label + " was =" + oldValue + "; now =" + newValue);
     }
    }
  });
  $("#_fid_342").html(log.join("\n"));
});
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Dan,
this fix works as far as it seeing the difference between the checkbok and the rest, but the code doesn't seem to log the proper values for the checkboxes
see log below. 
It doesn't matter what I change the checkbox to, it will say was on and now on. Also it seems to log all checkboxes, even the ones I don't change
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ROM Confirmed Completion was =on; now =on
Ready To Invoice - Notify AR was =on; now =on
In AR Review was =on; now =on
Rejected By AR was =on; now =on
Invoice Number was =21212; now =111111
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,094 Points 20k badge 2x thumb
Normally I test everything before I post but I didn't in this case and I should have.

Checkboxes are a little different than other form elements as to how their on/off value is represented. To get the current state of a checkbox you have to use this jQuery which returns true or false:

$("#_fid_" + fid).prop("checked");

Don't use this code to get the value of a checkbox: newValue = $("#_fid_" + fid).val();

So you will have to refactor the code to test (1) the type of the control ("checkbox" vs "text"), (2) if the oldValue is equal to the newValue and from there push the appropriate message into the log array.

I am afraid that I don't have time to write the code and I could likely make another typo or oversight unless I worked from a live demo (and I don't have time for that either).
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
I understand.
As always, Thanks for your contributions!
Photo of Yehudah Greenberg

Yehudah Greenberg

  • 600 Points 500 badge 2x thumb
Hi Dan, I've seen many of your posts dealing with IOL, but I haven't taken the leap to try it until now- The directions are simple enough, and it works great, thank you!
I am having a bit of an issue logging changes to a "user" field; changes to my user field don't show up in the text field that logs all the other changes.  Is there a way around this?
I have also notices that changes to multiple choice "radio" buttons don't log; changes to these fields only log when they are pull-down menus.
Photo of Rebecca Goetz

Rebecca Goetz

  • 60 Points
Hi, I've gone through this thread and while it's been immensely helpful I still can't get this to work for me. Here is my code:

$("#_fid_17").attr("readonly", "readonly");

var label, oldValue, newValue, log;

$("#_fid_6, #_fid_7, #_fid_8").on("change", function() {

  log = [];
  _.each([6, 7, 8], function(fid) {
    oldValue = $("[name=_fid_oval_" + fid + "]").val();
    newValue = $("#_fid_" + fid).val();
    if (oldValue != newValue) {
      label = $("label[for=_fid_" + fid + "]").text();
      log.push(label + " was =" + oldValue + "; now =" + newValue);
    }
  });

  $("#_fid_17").html(log.join("\n"));

});


I've done some basic debugging with alerts and the code runs through completely, but nothing appears in my [Log] field (which is ID 17 and is a multi-line text field).