- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 02:08 AM
Hi,
I wrote an onload client script :
function onLoad() {
var isAdmin = g_user.hasRole('admin');
if (isAdmin){
g_form.setReadOnly('u_withdraw_credit_in_advance',false);
g_form.setReadOnly('u_deposit_real_money',false);
} }
but the fields stay readonly.
I saw with the debug that a ui policy occurs after the client script and changes the fields back to readonly.
How can I implement it so it will override the ui policy?
Thank you in advance,
Shany
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 02:12 AM
Hello Shany Ben,
If you write Client script and UI policy on same field. Client script will execute first. You can write either client script or Ui policy for the same action.
For more info refer the below link.
A Race between UI Policy and Client script
Note: Always use UI policy instead of Client script which is a best practice.
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 02:09 AM
I have the same question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 02:12 AM
Hello Shany Ben,
If you write Client script and UI policy on same field. Client script will execute first. You can write either client script or Ui policy for the same action.
For more info refer the below link.
A Race between UI Policy and Client script
Note: Always use UI policy instead of Client script which is a best practice.
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 01:41 AM
for same scenario in my instance UI Policy executed first, how did that happened?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 02:13 AM