Page 1 of 1
Using #nu_user_name# as default field value
Posted: Tue Oct 14, 2014 2:24 pm
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".
Re: Using #nu_user_name# as default field value
Posted: Tue Nov 04, 2014 3:27 am
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