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,434 Points 20k badge 2x thumb
Yes this is possible. An append or prepend text field (QuickBase calls this property "Log entries" now) accumulates a short log of changes to itself. However, when used in conjunction with the image onload technique you can gather those fields that have been changed along with the old and new values and stamp this information into the append or prepend text field. In other words, the append or prepend text field would never receive human keystrokes - rather the script injected into the page will monitor for changes to field values and assemble a string of text reporting these changes and automatically insert the generated text into the append or prepend text field. When the form is ultimately saved the append or prepend text field will be holding a miniature report of changes to all fields being logged and QuickBase will stamp the date/time and user using the native operation of the append or prepend field.. This may seem fantastic that you can do this but the edit form actually contains both the new values of the fields and the old values of the fields in hidden form elements.

I will come up with an example shortly - I have to finish watching my morning cartoons now.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
I don't care about the stupid points. Asking a new question just helps focus someone tagging on a new question to an old post. But don't even bother since there is a demo I created that does this and I should have included it in my reply. I just have to find it ...

hang on
Photo of Joshua Tate

Joshua Tate

  • 1,016 Points 1k badge 2x thumb
:D - sent you an email but all good how ever we go lol
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
Here is your example:

Come Mr Tally Man Tally Me Bananna
https://haversineconsulting.quickbase.com/db/bi5q4vzj9



Edit Record 1 and Log Everything Like the NSA Does
https://haversineconsulting.quickbase.com/db/bi5q4vzmc?a=er&rid=1

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=305

Notes:

Back to watching cartoons ...
Photo of Samuel Trachy

Samuel Trachy

  • 82 Points 75 badge 2x thumb
Hey Dan, 

First of all, Big Fan! Long time listener, first time caller:  

Looks as though the "Edit Record 1 and Log Everything LIke The NSA Does" link no longer works.  I'm trying to implement this solution as well and I'm running into some issues and I'm thinking I may just not be seeing the whole picture.  Help?

thnx - Sam Trachy
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
You have SEVERAL additional errors in your code - I apparently just reported the first one I saw. Corrected here:

http://pastie.org/9493321

You can minimize errors like this (everyone makes them including experienced developers) by using a variety of tools.

JSBeautifier will format you code:
JSBeautifier
http://jsbeautifier.org/

JSfiddle has a "linting" tool built into it which will identify syntax errors:

JSfiddle with JSHint
http://jsfiddle.net/rnp058hc/

The text editor Notepad++ has syntax highlighting and matching brackets highlighting which will help you find unbalanced brackets:

Notepad++
http://notepad-plus-plus.org/
There are thousands of similar tools available so pick those that you are comfortable with.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,434 Points 20k badge 2x thumb
>I still have the issue with not being able to log edits to lookup fields though.
A lookup field can only change when the [Related Parent] field changes. To get the old and new values of the lookup filed you have to perform two AJAX requests to the parent table using (1) values of the [Related Parent] stored in the hidden input associated with the [Related Parent] <input> as seen here for fid=7:
<input name=_fid_oval_7 type=hidden value='1'>

and (2) values of the [Related Parent] associated with the selected option of the [Related Parent] <select> as seen here for fid=7:
<SELECT size=1 name='_fid_7' id='_fid_7' ...> <option value="" style="color:#888888;"> Make a Selection... </option> <option value="1" >Record #1 - foo - 123</option> <option value="2" selected>Record #2 - bar - 456</option> <option value="" style="color:gray;" disabled>--------</option> <option value="_other">&lt;Add a new record...&gt;</option> </SELECT>
The value of the lookup field from the AJAX call in step (1) will be the old value, while the value lookup field from the AJAX call in step (2) will be the new value. Note that even if a new parent record is selected it may be the case that the lookup field does not change value even though the related parent record does change - you may or may not want to note such a situation in your log.