
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 11:46 AM
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);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 12:01 PM
- function onLoad() {
- var uval = g_form.getValue('req_by_for_requested_by') ;
- if (uval == '')
- {
- g_form.setValue('user',g_user.userID) ;
- //alert(uval);
- }
- }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 11:49 AM
You can't use gs. in a client script, try g_user.userID

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 11:53 AM
Or set the default value of the field or variable to
gs.getUserID();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 12:01 PM
- function onLoad() {
- var uval = g_form.getValue('req_by_for_requested_by') ;
- if (uval == '')
- {
- g_form.setValue('user',g_user.userID) ;
- //alert(uval);
- }
- }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 12:12 PM
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);