Using #nu_user_name# as default field value

Using #nu_user_name# as default field value

Postby agnar » Tue Oct 14, 2014 9:54 pm

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".
Posts: 37
Joined: Mon Apr 22, 2013 6:28 am

Re: Using #nu_user_name# as default field value

Postby massiws » Tue Nov 04, 2014 11:57 am

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 { 
= 'globeadmin';

$js  = "function getUserName(){return '$username';}";

Then, use the JS function where you want; for example, in Javascript tab insert:
Code: Select all
function nuLoadThis() {
    var uname = getUserName();

    // To assign userName to a text object
    $( '#my_object_id' ),val( uname );

Hope this helps,
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Return to General