- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 01:39 PM
Hi Team!
I am working in the Agent Workspace area and am trying to recreate a UI scrip that functions in our ServiceNow UI however, in Agent Workspace, there seems to be some difficulty and thats why I am reaching out.
On the incident table, if an Agent selects a Business Service (business_service) of Software, I need to show the software selction box (u_software) and make it mandatory.
I have this in a Client Script, sitting in the Agent Workspace application, Incident table, UI Type: All, Type: onLoad, and have Isolate script checked.
My current code:
function onLoad() {
if(g_form.getDisplayBox('business_service').value == 'Software') {
g_form.setDisplay('u_software',true);
g_form.setMandatory('u_software',true);
}
else {
g_form.setDisplay('u_software',false);
g_form.setMandatory('u_software',false);
}
}
I cannot get this to work. Perhaps someone out there can assist?
Thanks;
Dave
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:00 PM
If you just remove the "if" that is checking isLoading you probably can skip the onLoad script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 02:41 PM
I believe you have half the problem solved with the onLoad() client script. onLoad() will only make the visual changes when the form loads. onChange() is the other half of the problem and is a separate UI script.
onLoad() - Field has current value. Perform action.
onChange() - Field changes value. Perform action.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(g_form.getValue('field') == 'value'){
g_form.setDisplay('field', true);
} else {
g_form.setDisplay('field', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 02:52 PM
I believe you are right!
Many thanks! Sometimes I just can't see the forrest for the trees.
I appreciate the help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:00 PM
If you just remove the "if" that is checking isLoading you probably can skip the onLoad script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:21 PM
Thank you!
This worked brilliantly. Now I need to figure out how to mark both as correct!