Is it possible to create a user activity log with Wappler?
I want to build a very simple document management system which allows a user to login, view files like pdfs, and Admin should be able to see which files the user accessed and what time user logged in.
Is this something Wappler can do? If yes, which tutorials should i be looking at?
Hi @enyonam
You can do this with Server Connect which stores the specific actions in a database table, so you can run it on click of a link, on page load, on login etc.
It’s a simple insert record, which inserts the information you need in your table
Hi @Teodor thanks for the response. If I understand your reply, then it means this can be done by using the Dynamic Events section of Wappler. So for example, Just as I display a notification after a successful action, I can use the same process to insert a Db record. My question then is where do i pick the entries to be inserted.
Is there an existing similar tutorial on how to insert db record on success of form submission.
I have created a new table called useractions which has 4 columns namely :
I have a working login form on a page. Now assuming I want to record/log all user logins into the useractions table, how will I will get this done. I believe with this example, I will be able to replicate it for all other things I want to log.
Add GET variables for every value you want to insert
Create a database insert action and use the GET variables as values in the appropriate database columns for your database insert
On the page
Add this server action on the page. Set it to NO AUTO LOAD
Use the dynamic events > success to run your “insert log” server action. Add the values you need to the GET parameters (they will be listed as parameters for the server action)
Your solution worked for me. I am able to record some actions. @Teodor i tried implementing your solution on another page but got stuck a point. Will pick it up again and revert.
A related question is, how do I get the logged in user’s username as part of the data to be stored in the db.
But another issue that arise is how to record a login action.
I followed the @ben recommendation with the hidden form.
I set up a hidden form with the fields i specified in my earlier post.
actionID
actionName (eg: Static Value)
actionTime (picking from the DateTime component)
actionUser. (I am picking this from the username field of the login form. i.e the entered value)
-The Login system works fine.
-The Error Alert on wrong details works fine.
the redirection based on accesslevel works fine.
I have added a dynamic event onSubmit of the Login Form, the data is inserted in the DB. This works fine with a glaring issue. Even when a wrong username is entered and the login throws the invalid errorAlert, the data is still inserted in the db.
I changed the Dynamic event from onSubmit to onSuccess and it didn’t work at all.
I know I am doing something wrong. Just don’t know what exactly.
How would I achieve this when i store this form in a SSI php include, eg. a navbar? App-Load or Ready doesn't trigger my INSERT then
EDIT: Nevermind, I figured some other solution. When using session variables instead of cn_getuserdetails to pull the values every time, the procedure works with Autosubmit forms as well.