- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 05:21 PM
Hi All,
I am not a Java dev and I just need some help on how to set a value to be the current logged in user if a checkbox is true
Variable is requestor
Default value is javascript:gs.getUserID()
If checkbox "newuser" is false then I want to set requestor to the logged in user, else set the request to blank.
By Default the newuser feild is false. The requestor feild loads correct with the logged in users name.
If i set new user to true it makes request blank which is great.
If i then set new user to false again the requestor stays blank. I want the requestor to be the logged in user.
Here is what I have so far, Can anyone help?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue("requestor",************);
}
if (newValue != '') {
g_form.setValue("requestor","");
}
}
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 06:59 PM
Here you go
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
g_form.setValue("requestor",g_user.userID);
return;
}
if (newValue == 'true') {
g_form.setValue("requestor","");
}
else{
g_form.setValue("requestor",g_user.userID);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 05:30 PM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
g_form.setValue("requestor",g_user.userID); //assuming you want to run it during onLoad as well.
//return;
}
if (newValue) {
g_form.setValue("requestor","");
}
else
{
g_form.setValue("requestor",g_user.userID);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 05:56 PM
unfortunately not changing the value back still.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 06:07 PM
Updated code below. This should work.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue("requestor",g_user.userID);
//return;
}
if (newValue == 'true') {
g_form.setValue("requestor",g_user.userID);
}
else
{
g_form.setValue("requestor",g_user.userID);
}
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 06:59 PM
Here you go
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
g_form.setValue("requestor",g_user.userID);
return;
}
if (newValue == 'true') {
g_form.setValue("requestor","");
}
else{
g_form.setValue("requestor",g_user.userID);
}
}