We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

setting logged username by using client script

Not applicable

Hello folks ,

I have a field name called "user" this field is referenced to "sys_user" table . Now i would like to write a client script to setValue default logged user name in this field .

Is there any way to set the value by using client scripts ? Because when i try to write   below script is hitting error .

function onLoad() {

   

var uval = g_form.getValue('req_by_for_requested_by') ;

if (uval == '')

{

var user = ga.addQuery('user_name',gs.getUserName());

g_form.setValue(user) ;

//alert(uval);

}

}

1 ACCEPTED SOLUTION

Deepak Kumar5
Kilo Sage
  1. function onLoad() {  
  2.        
  3. var uval = g_form.getValue('req_by_for_requested_by') ;  
  4. if (uval == '')  
  5. {  
  6. g_form.setValue('user',g_user.userID) ;    
  7. //alert(uval);  
  8. }  
  9. }

View solution in original post

5 REPLIES 5

Richard78
Giga Contributor

You can't use gs. in a client script, try   g_user.userID


Jace Benson
Giga Sage

Or set the default value of the field or variable to


gs.getUserID();


Deepak Kumar5
Kilo Sage
  1. function onLoad() {  
  2.        
  3. var uval = g_form.getValue('req_by_for_requested_by') ;  
  4. if (uval == '')  
  5. {  
  6. g_form.setValue('user',g_user.userID) ;    
  7. //alert(uval);  
  8. }  
  9. }

Yes what Deepak said ^^^


Question though, now that I fully looked at the script, is the field your trying to populate the req_by_for_requested_by? If so line 7 should read as follows:


g_form.setValue('req_by_for_requested_by', g_user.userID);