g_form.showFieldMsg Client scripts is not working on portal

manibaig
Mega Guru

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);
}
}

1 ACCEPTED SOLUTION

Stacy1
Mega Guru

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');
}
}

View solution in original post

14 REPLIES 14

I tried annotation but you are right it won't work or other form messages. it's working fine in ServiceNow but not on portal which is strange. if there was any error in client script it shouldn't work at all

standard form (sys_approval)

Stacy1
Mega Guru

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');
}
}

Jude S
Tera Contributor

I had the same issue recently where the g_form.showFieldMsg(..) was not displaying the message on portal.

If you try to clear the value using  g_form.clearValue(..) straight after the g_form.showFieldMsg(..) it will not display the error message.

Instead clear the value prior to displaying the error message.

 

 

This does not work!

g_form.showFieldMsg('contract_end_date','Pleaase select a date which is in the future.','error');
g_form.clearValue('contract_end_date');


Solution

g_form.clearValue('contract_end_date');
g_form.showFieldMsg('contract_end_date','Pleaase select a date which is in the future.','error');

Shruti17
Kilo Contributor

it is still not working. even alert pop up is also not visible in portal. however in try it it is getting displayed. I think there is some settings we need to do for portal side.