- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-07-2018 07:57 PM
UI Type= All. Below script works fine in servicenow(Kingston) but it's not working on portal. Field message does display on portal for a split second though . Any suggestions guys Thanks
function onLoad() {
var WTest = g_form.getValue('u_w_status');
if ( WTest== 'Awaiting') {
// alert('What');
g_form.showFieldMsg('WTest','Disclaimer .........' , 'info' , true);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-24-2018 08:31 AM
the info,true works great for me. Are you remembering to hide the message also if it's false.
Here is an example of my script and it works great on the portal.
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == 'prod') {
if (g_form.getValue('var_environment') == 'prod'){
g_form.showFieldMsg('var_environment', 'INFORMATION: Sandman will not run against this environment','info',true);
}
else{
g_form.hideFieldMsg('var_environment');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-07-2018 08:08 PM
Is this running on a catalog item or a standard form in Service Portal?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-07-2018 08:13 PM
This should work, but you need to supply the name of your field/variable instead of the 'WTest' variable name. Try changing your script to this...
function onLoad() {
var WTest = g_form.getValue('u_w_status');
if (WTest == 'Awaiting') {
// alert('What');
g_form.showFieldMsg('u_w_status','Disclaimer .........' , 'info' , true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-07-2018 08:24 PM
i changed the script and removed row 2
if(g_form.getValue('u_w_status')== 'Awaiting')
still same issue.
Alert('') works fine though

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-07-2018 08:28 PM
Also, I'm seeing that these messages disappear if the field value changes so you'll need to make sure you re-show the field message each time the field changes. You'll probably have better luck running this as an 'onChange' script against the 'u_w_status' field.
function onChange(control, oldValue, newValue, isLoading) {
// Hide the field message if present
g_form.hideFieldMsg('u_w_status', true);
if(newValue == 'Awaiting') {
// Re-show the field message
g_form.showFieldMsg('u_w_status','Disclaimer .........' , 'info' , true);
}
}