- 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 09:20 PM
Thank you this worked perfectly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 10:15 PM
Hey Nicole,
Is the code I shared not working with removing g_form.setValue from IsLoading block? The reason I ask as you already have default value set via variable default value javascript:gs.getUserID() so the setValue line in the script is no longer required.
Thanks,
Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 08:17 PM
I have further modified your code. Here you go.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'true') {
g_form.setValue("requestor",g_user.userID);
}
else
{
g_form.setValue("requestor", '');
}
//Type appropriate comment here, and begin script below
}