You can create a record in a "UsersLog" table and put in info by using your startup script including Get(AccountName) and Get(CurrentTimeStamp).
You can create another record (or modify or add to the first one) in your exit script for exit time.
You can then create reports or calculations from there.
There are a number of ways to clear it out, including a record containing "Last cleanout date" and checking against this for elapsed time and re-clearing records again.
If (Get(CurrentDate) > LastCleanoutDate + 30)
GoToLayout [UserLog (UserLog) ]
Show all records
Delete All records
SetField [ Admin::LastCleanoutDate ; Get(CurrentDate) ]
or some such...
I have a users table. How do I build the login script to get account name and make a calculation in that record so I can place the time stamp and other information? Sorry, little bit of a FMP novice. Thanks!
You can use file options to select scripts to run when the file is opened or closed.
A script such as:
Enter Find Mode 
Set field [UserLog::AccountName ; Get ( AccountName ) ]
Set Field [UserLog::LogCount ; UserLog::LogCount + 1 ]
Set FIeld [UserLog::TimeIn ; Get ( CurrentTimeStamp ) ]
can capture log in data.
and a similar script running at file close can log the timestamp when the user logged out.
Keep in mind though that if a user's copy of filemaker crashes or they are disconnected from the network, the "close" script won't run and your UserLog will still show the user as being logged in when they aren't.
Assuming that your users table is ONLY used for user tracking:
Make five fields on your Users table: Account (text), Entry (timestamp) and Exit (timestamp) and RecordID (autoenter serial) and gID(global text).
Make a layout based on this table called "Users" (you probably already have this)
In your startup script (File>File Options, When opening this file Perform Script....) have something like:
GoToLayout [ "Users" (Users) ]
SetField [ gID ; Users::RecordID ]
SetField [ Users::Account ; Get (AccountName) ]
SetField [Users::Enter ; Get (CurrentTimeStamp) ]
GoToLayout.........add the rest of your startup script here....if you don't have any more, choose the layout you want them to start on.
In your Exit Script (File>File Options, When closing this file Perform Script....) have something like:
GoToLayout ["Users" (Users) ]
Enter Find Mode
SetField [RecordID ; Users::gID]
Set ErrorCapture [on]
SetField [Users::Exit ; Get(CurrentTimeStamp) ]
Get to this point and we'll work on the clearing out part...
Keep in mind how many log ons and log offs there will be. How many records would this make in 30days? enough for the find to slow your system down? That could be a problem for you... How many would you expect? If there are a lot, we can approach this a slightly different way.
Thank you so much!!!
How would I write a calculation so I could say:
" 'John Doe' logged in X times in the past seven days "
Well, it depends.
How would you like to define it? Will it be for a manually selected user, all users, always seven days, do you need to store these results?
I guess the question is: What type of reviewing would you do?
Then we'll build an interface to give you that.
One way to review the usage would be a sub-summary report sorted by user. Phil wrote a nice tutorial on subsummary reports that you can find here:
Another way would be to have a layout where you typed in the start and end dates of interest and have the users listed with the number of logins each one had between those dates (filtered portal)
If you are simply looking for abuse or neglect, you could define parameters that suggest these and calculate these.
There are many options, which make sense in your situation?