Current Logged in Username

Hi Folks,

I am just wondering how I would go about retrieving the current user on my Filemaker Pro database. I assume I will need to use a script with the Get(AccountName) function, but it isn't working. I am probably doing something wrong, but do not know what.

Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

there is example usage here, does this help any?
read the note here about running script under admin privilege
CompTeck2255Author Commented:
Hi rockiroads,

Thanks for your reply, the solution above (ElseIf) won't really help me I don't think. I am wanting to display the current user in either a text box or field. Do you know how I would go about doing that?
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

So running it Get(AccountName) did not do anything? what was your error?
CompTeck2255Author Commented:
I didn't receive any error because the example isn't what I am after. Why would I start with a ElseIf step for?
urm the example was how one can use it. I am not telling u to use elseif

u said u used it but didnt work, so need more info on how you used it and what it failed with
CompTeck2255Author Commented:
Right. I have the following in my script atm.

Set Field [Home::current_user; Get( AccountName )]

But on the field "current_user", nothing shows. Have I made a mistake in my syntax?
Im reading this so do you need to use Home?
CompTeck2255Author Commented:
Home is purely the name of the layout/database I am using.
CompTeck2255Author Commented:
Actually, it is now working, but only when I add a new record, is it possible to have it set-up so it shows on file load?

I think you need the script step "Get ( AccountName )"  
This will return the name the user used to sign in to filemaker.

Hope that helps
Set your user name field to 'global' (so that the logged in user's name appears on all records, and not just the record the script was on when the Get(AccountName) script step was executed).
CompTeck2255Author Commented:
Hi ThomDroz and Tocacar,

Thanks for your additions. I do believe I am using the Get ( AccountName ), as mentioned in posts above. Thanks for the idea of setting the field to global, but is there anyway to get the name to appear when I open the file, currently it only shows after adding a record ?
Create a script (call it 'login' script or something) and in File/ File Options select it using 'Perform this script' in the 'When Opening This File' section of the dialog box.

Now, presuming you have set the username field to be a global field, your login script can do anything else you want it to, but it should include a 'Set Field' script step that sets the global field to Get(AccountName).  You won't need to go a layout that supports the table holding the global field as global fields can be populated from anywhere in the database.  You may want to go to that layout anyway, in which case do.

Make sure that the username field does not have any auto-entry stuff selected in the field definition area (you may have set an auto-enter calc to display the account name, for example).

Let me know how you get on.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTeck2255Author Commented:
Hi Tocacar,

Your a 'Master' :-). That worked perfectly. Just quickly, with the 'global' setting, would it be possible to set my 'created by' and 'timestamp' fields to global so I don't need them in any more than my first table?

Thanks again.
Glad to help!  

You won't want to do the created by and timestamp fields as global.  Global fields are session and user specific and revert back to empty after each user session (if the system is hosted by Filemaker Server).  You need to keep the auto-entry settings for these fields and they will be populated correctly each time a record is created.

There was another recent EE question re; global fields and their use which you may find interesting/ useful:
CompTeck2255Author Commented:
Thanks for that information.
CompTeck2255Author Commented:
Thanks for the great support
Hi, I went to bed soon after my last post so missed your replies but glad your all sorted now. Just to try improve on the help you get try to ask what you want (username on load) initially. I have not got filemaker on me to verify my post but sounds like it might of been working.
CompTeck2255Author Commented:
Thanks for your additions rockiroads :).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.