Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Using #nu_user_name# as default field value

Post Reply
agnar
Posts: 37
Joined: Sun Apr 21, 2013 10:58 pm

Using #nu_user_name# as default field value

Unread post by agnar »

Is there a way to assign the vale of #nu_user_name# as default value to an attribute field.

Have tried SELECT '#nu_user_name#', But I am getting "#nu_user_name#" as the default value, not "agnar".
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Using #nu_user_name# as default field value

Unread post by massiws »

agnar,
maybe you have already find a solution, otherwise you can define a custom function in Before Open to get user name from DB:

Code: Select all

$uid = $_SESSION['nu_user_id'];

if ($uid != 'globeadmin') {
    $res = db_fetch_object(nuRunQuery("SELECT sus_login_name FROM zzsys_user WHERE zzsys_user_id = '$uid'"));
    $username = $res->sus_login_name;
} else { 
    $username = 'globeadmin';
}

$js  = "function getUserName(){return '$username';}";
$this->appendJSfunction($js); 
Then, use the JS function where you want; for example, in Javascript tab insert:

Code: Select all

function nuLoadThis() {
    var uname = getUserName();
    alert(uname);

    // To assign userName to a text object
    $( '#my_object_id' ),val( uname );
    
}
Hope this helps,
Max
Post Reply