Creating an Error Message in Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2017 01:18 PM
I'm a novice in JS so I'm having some difficulty making a client script to make an error message on the Demand form to tell the user they need to answer a question in a choice field before continuing if the "portfolio" field contains a value of "AIT." Any suggestions would be very appreciated! At this point I have not found a suitable script to tweak for my purpose, but I do know I probably need to use "getErrorMessage." Thanks!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2017 01:58 PM
Hello Aubrey,
If my understanding is correct then the user might either select yes or no as an option. Correct?
If yes then you need to check if there was any modification on field or not. Sample script.
var chk = g_form.getControl('PASS FIELD COLUMN NAME OF CHECKBOX HERE');
if(!chk.changed)
{ //enter the loop if user has not taken any action.
alert('a');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2017 01:24 PM
Look at Scripting Alert, Info, and Error Messages - ServiceNow Wiki , this should help your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 01:40 PM - edited 04-06-2023 01:43 PM
Hi guys!
In my case I used a default GlideModal to display an 'alert message', on the client side, code example:
function your_func (whatever_condition) {
if (!whatever_condition)
return modalAlert();
}
function modalAlert() {
var gm = new GlideModal('glide_info', true, 600);
gm.setTitle('Atention!');
gm.setPreference("title", 'your message');
gm.render();
}