UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 08:46 AM
i have a field on form requirement is if a checkbox is not ticked then it should appear a message that "you dont have xyz account and raise the request through https:xyz.com link.
under ui policy script i wrote this but it isnt working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 09:04 AM
Hi @vikaskumarc,
---------------------------------------------------------------------------------------------------------------------------------------------------
You are using set value which basically sets the value of mentioned field
If you just want to show an Info/Error message, Try these Glide form methods ->
g_form.addInfoMessage('The top five fields in this form are mandatory');
g_form.addErrorMessage('This is an error');
g_form.addFormMessage('info message','info');
// for fields
g_form.showFieldMsg('impact','Low impact response time can be one week','info');
and reference link for other methods -> GlideForm (g_form) | ServiceNow Developers.
Do let me know if you need further help.
---------------------------------------------------------------------------------------------------------------------------------------------------
Please mark my response helpful and accept as solution
Thanks & Regards
Mayank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 09:05 AM
Hi!
You have some options :
1)alert("test"); before g_form.setValue
-like this you will see if the script actually runs
2)open dev tools on your browser and check the console for any errors when trying to trigger the ui policy.
Hope those will help you to identify your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 09:09 AM - edited 07-26-2025 09:11 AM
Hello @vikaskumarc !
setValue merely writes that text into a table field. It won’t display anything to the user and if the field is read‑only, nothing appears to change. Replacing it with showFieldMsg or addInfoMessage (or a no‑code UI‑Policy action) solves the problem.
Below I wrote a short Client Script that does what you need:
// Client Script -> Type: onChange, Field name: xyz_account_checkbox
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return; // ignore the form load event
// build the message once so you can reuse it
var msg = 'There is no XYZ account for the selected user. ' +
'You can raise an access request ' +
'<a href="https://xyz.com" target="_blank">here</a>.';
if (newValue == 'false') { // checkbox is NOT ticked
g_form.showFieldMsg('xyz_account_checkbox', msg, 'info'); // show message under the box
// alternatively: g_form.addInfoMessage(msg); // banner at top of form
} else {
g_form.hideFieldMsg('xyz_account_checkbox', true); // clear the message
g_form.clearMessages(); // and clear any banner, if you used addInfoMessage
}
}
Please consider marking my answer as helpful and accepting it as the solution if it assisted you in any way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2025 09:57 AM
On that checkbox 1 ui policy is already applied to set that read only. Is that the issue on load client script not working.