Record Update Log (Object Based)

Hello Folks!

Today we’ll show you what and how to record the sequence of events of each user in a knack application. Please take into consideration that everytime someone in the platform performs an action such as insert, edit or delete, it must be logged in a table. This way you will be able to keep an internal control of all movements made in the application by all users for audit purposes.

The most important data to record in the log are:

  • User who carried out the event
  • Date and Time
  • The object
  • If it was an insert / update or delete

Below we outline the process for the implementation of the Record update log:

1. Create new Object in Builder


2. Add 4 fields to new Object:

  • Action as Multiple Choice with 3 options (insert, update, delete)
  • Object Name as Short Text
  • User as Connection with Default User Object
  • Date/Time with default date and time options selected


3. Insert the following code in the API & Code section of the APP (replace your information):


// Replace with your Knack APP Info





// Replace info with your Knack "Record Change Log" Object



 * Create new record log.

 * @param action Log Action (insert | update | delete)

 * @param objectId Knack Object Id


function createRecordLog(action, objectId) {

  var user = Knack.session.user;

  if (!user) {

    // Not authenticated



  var knackObject = Knack.objects.models.find(function (item) {

    var record = item.toJSON();

    return record.key === objectId;


  if (!knackObject) {

    throw new Error(

      'Object ' + objectId + ' does not exist in this Knack App.'



  return $.ajax({

    type: 'POST',

    headers: KNACK_HEADERS,

    url: Knack.api_url + '/v1/objects/' + OBJECT_RECORD_LOG + '/records',

    data: {

      field_XXX: action, // Replace field_XXX for User field ID

      field_YYY: knackObject.toJSON().name, // Replace field_YYY for User field ID

      field_ZZZ: // Replace field_ZZZ for User field ID




// Knack events for insert and update

$(document).on('knack-form-submit.any', function (event, view) {

  createRecordLog(view.action, view.source.object);


// Knack event for delete 

$(document).on('knack-record-delete.any', function (event, view) {

  createRecordLog('delete', view.source.object);


4. As users use the Knack forms to add, update, or delete records, the log records will be visible in the new object created in step 1:


We hope you can incorporate this in all your Knack applications!

If you liked this subject in particular, please let us know by leaving a comment below.

Hey David - thanks for the warning.  Any chance you could provide some guidance on implementing this safely?

Once again, DO NOT use this as is. It will expose all the data in your app to anyone on the internet. Use view-based API calls instead, and never put your API key in your code.