- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 01:59 AM
Hi,
I am trying to create a UI Policy to hide the Task table filed 'time_worked' when users who do not have the role 'timecard_user' are looking at Requests.
Unfortunately the UI policy doesn't work when the specified Table is 'Task' (although it does work when the specified table is 'Request') can anyone advise what is wrong with the condition (see screen-shot) or my script?
Thanks,
Arthur
------------------------------------------------------------------------------------
function onCondition() {
// we only want users in the group 'Time Card Users' to see this field
if (g_user.hasRole('timecard_user')) {
g_form.setDisplay('time_worked', true);
}
//Non 'Time Card Users' we dont want to see the field
else
g_form.setDisplay('time_worked', false);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 02:06 AM
Hi Arthur,
Can you please enable the Inherit checkbox in UI policy. This will applies to the extended tables also.
Please hit like or mark the response as helpful or correct based on the impact!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 02:04 AM
Hello Arthur,
Maybe the following might be helpful.
UI policies
UI policies are client-side logic that governs field behavior and visibility on forms.
ServiceNow automatically generates client-side Javascript that the browser executes to enforce policies on the form being displayed. Each policy has a condition that must resolve as true to be executed. Policies determine the following field attributes and behaviors:
- Make the field mandatory
- Show or hide the field
- Make the field read-only
Most basic UI policies are declarative and do not require scripting. You may also write your own scripts to handle more complex scenarios.In the example below, no scripting was required to:
- Make the Number field read-only
- Make the Configuration item field mandatory
- Hide the Priority field

Note: Another client-side script within ServiceNow, called a client script, can also be used to hide/show fields and make fields mandatory. For faster load times, use a UI policy instead of a client script when the only purpose of the script is to set a field to show/hide, read/write, or mandatory/optional.
Thanks,
Dravvy
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 03:46 AM
Hi Dravvy,
The background info has been very useful.
Thanks,
Arthur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 02:06 AM
Hi Arthur,
Can you please enable the Inherit checkbox in UI policy. This will applies to the extended tables also.
Please hit like or mark the response as helpful or correct based on the impact!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 02:26 AM
HI Pavan,
Thanks for pointing that out, it's much appreciated.
Best regards,
Arthur