- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 05:21 AM
When a particular checkbox is checked, and the 'req_level_safe' value does not equal 'none', the user will receive a pop up message (working currently), and the values of 2 select box variables should be cleared. My script will not clear the values:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
var accOnly = g_form.getValue('access_only_checkbox');
var reqSafe = g_form.getValue('req_level_safe');
var reqFac = g_form.getValue ('req_facility_clearance');
var message = 'If subcontractor will have or require access only at Government or contractor facility, then Safeguarding may only be NONE.';
if(accOnly == 'true' && reqSafe != 'none'){
g_form.setValue(reqFac, '');
g_form.setValue(reqSafe,'');
alert(message);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 06:02 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 05:26 AM
Greetings Nicole,
Try clearValue. https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GlideFormClearValue_String
-Andrew Barnes
Join me at Developer Blog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 05:27 AM
If it is a check box and you want to uncheck then, you have to set the value as false rather than "'
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
var accOnly = g_form.getValue('access_only_checkbox');
var reqSafe = g_form.getValue('req_level_safe');
var reqFac = g_form.getValue ('req_facility_clearance');
var message = 'If subcontractor will have or require access only at Government or contractor facility, then Safeguarding may only be NONE.';
if(accOnly == 'true' && reqSafe != 'none'){
g_form.setValue(reqFac, false); //If it is checkbox, set value as false
g_form.setValue(reqSafe,false); //If it is checkbox, set value as false
alert(message);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 05:37 AM
They are not check boxes, they are select boxes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 06:02 AM