- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 02:23 PM
I have a "selector" field on a form that references the sys_user table. It is a "List" type field so uses the little padlock icon to open the selector and select multiple values from the user table. I have 3 choices in another select box field. If "Yes - IS Global Only" is selected it displays the selector field and allows the requestor to select a user from the table. I need to auto-set a user in the selector if the option of "Yes - IS Global Only" is selected from the select box field. I used the following client script but it's not working:
function onChange() {
var SendNew = g_form.getValue('u_send_notification');//Select box field choices
if (SendNew == 'Yes - IS Global Only'){ //'Yes - IS Global Only' is one of 3 options
g_form.setValue('u_notify_user', 'IS Global');//Set the User in the selector box to IS Global
}
}
Any input would be appreciated. Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 08:52 PM
Hey Mike,
That should be fine. I am glad I was helpful to you. I am pasting the script and final code here.
Script :
function onChange() {
var SendNew = g_form.getValue('u_send_notification');
if (SendNew == "Yes IS Global" || SendNew == "Yes"){
g_form.setValue('u_notify_user','08c5f8b42bfbb1007e94559bf8da155b');//IS Global sys_id
}
if (SendNew == "No"){
g_form.clearValue('u_notify_user')
}
}
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:32 PM
You mean you got blank alert for variable sendNew?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:35 PM
Yes, sorry that is correct. The blank alert was for sendNew

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:37 PM
So basically it will never enter the if loop as per the condition then. Just remove if condition and try to set the value to check if the value for who to notify is set or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:48 PM
Interesting....the onLoad function (script below) sets the default to IS Global, so that piece works. Anyway to set the condition that you know of?
function onLoad() {
//var SendNew = g_form.getValue('u_send_notification');//Select box field choices
//alert(SendNew); //make sure that the choice value is populated correctly
//if (SendNew == "Yes - IS Global Only"){ //'Yes - IS Global Only' is one of 3 options
//alert('in loop');
g_form.setValue('u_notify_user','08c5f8b42bfbb1007e94559bf8da155b');//Replace IS Global with the sys_id of the record
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:59 PM
So what is the exact if condition you are looking for?