Record when a User reads a record

How would I go about recording when the logged in user views a particular record?

We produce reports which need to be viewed by the workforce, but we need to be able to track which users have read (or not read) each report.

And is there is a function where you can limit the entries shown in a selection box to only the currently logged in user?

Thanks for any help.

Thanks Julian.

The examples seem quite sparse and I've hit a brick wall really.

There's nothing in the documentation about what the data object contains or the properties of the scene object.

I think this is beyond me sadly.

Thanks for your help though.

JB

Hi Jonathan

I think to do this you would need to change to a view-render (it's the view which contain the data) instead - see the syntax in the developer docs:

https://docs.knack.com/docs/javascript-jquery-examples

This would then give you access to the field values - there are several examples of doing this in the documentation.

Julian

ok, I have made some progress and I have the code writing a record to the User Log when the user views the page.

However, I need to be able to record exactly which record was viewed.

I tried to access elements of the data being shown on the page but was unsuccessful.

With a page render, how do I access the data being shown on that page?

I tried drilling down to it using the DOM like this:

var title = $('#view_63-field_17').value;

and then saving the title into the record, but that did not work.

Any help is much appreciated. I've learned a lot in the last few hours!

Yours,

Jonathan

 

 

 

Julian,

I've been looking at your code. I presume this line:

$(document).on('knack-scene-render.scene_51', function(event, scene) {
 
refers to the scene which you want to record a log event for? So in this case the scene that opens when a record is viewed is scene 51, which is why I have set the code to that.
 
Thank you for your help.
 
JB

 

Julian, that's really helpful, thank you.

I am still very new to Knack having been using it for about a week so far.

I have several questions.

1) I require a button that essentially allows the user to say "I have read this report".

2) Is there a way of filtering the source data when creating a table where you can say something like:

"Show Records that match 'all' of 'Viewed by' 'does not contain'

and then specify the currently logged in user? At the moment, the dropdown only allows selection of a specific user, rather than the currently logged in user.

Thank you for your help.

Jonathan

Hi Jonathan
This can be done in Javascript - and I have written a blog post about it which should help:

https://www.onlinedatabase.expert/post/adding-an-audit-trail-to-a-knack-app

Feel free to contact me if you need any help.

Julian