Workspace onLoad scrip to create visible and mandatory field if Business Service 'Software' selected.

David168
Tera Expert

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. 

find_real_file.png

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 

1 ACCEPTED SOLUTION

If you just remove the "if" that is checking isLoading you probably can skip the onLoad script.

View solution in original post

8 REPLIES 8

Not possible but as I think about it that maybe a good suggestion to put on the idea portal.  A way to say that these n+1 posts gave me the full answer to my issue.

DrewW
Mega Sage
Mega Sage

Have you tried just using a UI Policy for this?

 

Does a UI policy work the same in the Workspace environment? 

As far as I am aware they do.