Hi, I would like to create a log file of changes per user in a separate tab. I thought it might be possible with an action “Set column value,” but I cannot find an option to store this data in a different sheet. Any suggestions?
Use an Add Row action instead of Set Column Values.
Then you will be able to add rows to any table.
Hi @Darren_Murphy, is it possible to get the old value and new value when I’m logging this change, also the table name? I want one table with logs of all edits happening to the data on the app.
If you’re using custom forms, then it’s possible to capture and log before/after values, although there is no way to dynamically capture table names, so they would need to be hard coded into your logging actions.
Note that when using Glide Big Tables, there is a system Audit Log table that is automatically generated that captures most of this information for you.
@Darren_Murphy I just linked the Audit Log table to my app. But when I add a row to one of my tables from the layout page, it doesn’t get logged. Am I missing something?
Thanks for the tip though, this should solve most of my problems if I can get it to work!
To be honest, I’m not sure what does and doesn’t get logged. The docs suggest that it’s only API calls that are logged, but I know for a fact this isn’t accurate as I’ve seen other things logged in my own Apps. I think you’ll just need to experiment a bit.
Hmm, it’s not working that way for me. What’s the next best thing? Some things about the app I’m working on -
- Some tables have a lot of columns, so creating a template column with column values as replacements is not an option as suggested in some of the posts
- I’m not using a custom form, all default adds and edits
- It is important to know the before and after values when edited
I would use JSON.
Create a JSON column in each table that includes the current values of all columns. Use that as your “before” value. If you’re using native forms, then you would need to write that value into a User Profile row column as the form is opened, so that you can access it via an onSubmit action. Then you’d need a second JSON string to store your “after” values. You should be able to create this as part of an onSubmit workflow, but that’s not something I’ve ever tried, so again I think it might require a bit of trial and error.
Okay, I managed to get this working. It was some experimentation like you said @Darren_Murphy. Here’s what I did finally (names are specific to my app)
- Create a JSON column ‘Programme as JSON’ for the table I want to log changes for. Add all columns as values. This column will represent the current value always.
- Create a user specific column ‘Log/Before values’ in the Users table to store the before values of the row. This acts as the intermediary between the before and after actions of the form
- Create 2 workflows:
a. One for saving the before values in user column created in step #1 above when edit screen is opened. So, Show Edit Screen + Set column values
b. Another for logging the changes in a ‘History’ table.
Both of these will use the same table column value ‘Programme as JSON’, but since the workflows are triggered at different stages, they will hold different values - Use these workflows on edit and on submit. Note that adding to show detail screen will not work when the user decides to edit a second time from the detail screen. So this part is important.
This will need to be repeated for every table that needs to be a history log
Attaching screenshots for others’ reference.
Thanks for the direction @Darren_Murphy!
Nice job
Just one comment - and this perhaps falls just into the category of personal preference.
When defining JSON keys/values, I generally try to avoid any white space in my key names. So instead of “Programme Name”, I might use “programmeName”. Functionally it is the same, but it just makes it a bit easier if you need to manipulate or extract the data later on.
Ah, right. I will fix that
I have somewhat the same challenge a while ago. I use a JavaScript function to print the changes in a HTML table using diff library.