No announcement yet.

Logged username

  • Filter
  • Time
  • Show
Clear All
new posts

  • Logged username

    I have form and want save logged current username by adding new record into field "CreatedBy" in the database.

  • #2
    If you have a global variable containing the current username i.e. [glob_username] then you can go to to edit fields, go to the CreatedByField and set the default [glob_user] to the insert value. Check the forced value field.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development /


    • #3
      Thanks your reply, I'm new to Scriptcase.
      How can I create global variable containing the current username?


      • #4
        Welcome mokenned,
        Most of us here are fellow SC users. SC is pretty cool to use. The global vars are very easy.

        Essentially anything with brackets around it is a global var - you can use them in your PHP code in the events of any app.
        [glo_dog] = "this get stored in the global variable as a string";
        [glo_cat] = 1.257;

        You can also use the SC macro in your events to set globals as well. Help is onlinne:

        example of a macro from the help:

        $my_var = "mary";

        When you make a global var you can call it anything you want, but I usually make it have glo_ or something easy for me to spot months later when debugging.

        Another concept in SC is that globals can be coming in or going out of an app. If you look under application, global variables - you will see every global you have used in your event code. It goes in there automatically, as soon as you save code in any event. However, you usually have to specify which direction it is coming. I usually check SESSION and OUT, if I created the global in teh current app and will be using it in another app, like passing the second app a value it will need to process something. If the global is only being used in an app, as if it is coming from outside the app, check IN.

        You can do other things with globals, like using them in the settings of an app. Like putting a [glo_this_title] into the layout's title setting, then use an event like OnScriptInit or something to set the value based on your PHP code. You have to look at which events get triggered when (sometimes a tricky thing), but it works great. Globals are also involved in GET and PUT type parameter passing too - but you will have to look that up in the help and this forum.

        Good luck my friend,

        PS There is also a viewer built into SC that lets you see the global variables in the session while you are developing things. If you have used SC to create your security apps, they already set some things for you that you can reuse in other apps... explore around the login app events and see what is there.
        Last edited by onmountain; 07-06-2014, 10:43 PM.