Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Current Logged in Username

Posted on 2010-09-08
20
Medium Priority
?
823 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:CompTeck2255
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
  • 3
  • +1
20 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33633825
there is example usage here, does this help any? http://www.filemaker.com/help/html/scripts_ref1.36.7.html
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33633855
read the note here about running script under admin privilege http://forums.filemaker.com/posts/913fa9a3bb
0
 

Author Comment

by:CompTeck2255
ID: 33633926
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?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 65

Expert Comment

by:rockiroads
ID: 33633955
So running it Get(AccountName) did not do anything? what was your error?
0
 

Author Comment

by:CompTeck2255
ID: 33633970
I didn't receive any error because the example isn't what I am after. Why would I start with a ElseIf step for?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33633974
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
0
 

Author Comment

by:CompTeck2255
ID: 33634018
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?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33634053
Im reading this http://www.fmforums.com/forum/showtopic.php?tid/201024/ so do you need to use Home?
unsure
0
 

Author Comment

by:CompTeck2255
ID: 33634092
Home is purely the name of the layout/database I am using.
0
 

Author Comment

by:CompTeck2255
ID: 33634161
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?
0
 
LVL 6

Expert Comment

by:ThomDroz
ID: 33634842
CompTeck2255:

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
0
 
LVL 8

Expert Comment

by:Tocacar
ID: 33634923
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).
0
 

Author Comment

by:CompTeck2255
ID: 33635053
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 ?
0
 
LVL 8

Accepted Solution

by:
Tocacar earned 2000 total points
ID: 33635077
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.
0
 

Author Comment

by:CompTeck2255
ID: 33635187
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.
0
 
LVL 8

Expert Comment

by:Tocacar
ID: 33635239
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:  http://www.experts-exchange.com/Apple/Software/Filemaker_Pro/Q_26388220.html
0
 

Author Comment

by:CompTeck2255
ID: 33635287
Thanks for that information.
0
 

Author Closing Comment

by:CompTeck2255
ID: 33635288
Thanks for the great support
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33637093
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.
0
 

Author Comment

by:CompTeck2255
ID: 33642461
Thanks for your additions rockiroads :).
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question