KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Executing user specific code at database startup (Client/Server)
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: December 8, 2000

If you want to execute user specific code when a client logs in to a database, you usually specify a startup method in the Password dialog for that client. By doing so you ensure each time that user logs into the database the method will be locally executed on the client machine. This technique, although convenient, has one major drawback: a user that gets assigned a specific startup method CANNOT access the User environment. This applies even if that user has all the necessary privileges to do so.
Although in most cases you want user-specific code to be executed because those users are to work the Custom menus, you may still want to keep the option of them accessing the user environment. To do so, you need to detect those users in the On startup database method with a structure that would look as follows:

This way, the code will be user specific AND users will still be able to access the User environment, provided they have the privileges to do so.
Copy and paste the following into the method editor:
Case of
:(Current user="My User1")
`Do something
:(Current user="My User2")
`Do something
:(Current user="My User3")
`Do something
End case