Hide Field message is not working when 'none' is selecting in service

ramesh_r
Mega Sage

HI All

 

I have written the catalog client script foe showing the field message on the Choice List field, When choice value is selecting field message displaying properly but 

when 'none' option is selecting its should clear the existing value.

Note : This issue only on the Service Portal only,

I tried below codes but no use

 

UI type Selected : All

g_form.hideFieldMsg('type1', clearAll = true);

g_form.
hideFieldMsg('type1','Change functionality ','info',true);
g_form.hideFieldMsg('type1',true);
===============================================
The actual code below :-

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}


var type = g_form.getValue('type1');
g_form.hideFieldMsg('type1',true);

if(type == 'new_enhancement')
{
g_form.showFieldMsg('type1','Changein functionality ','info',true);
}

if(type == 'critial_breakfix')
{

g_form.showFieldMsg('type1','Production error','info',true);
}
if(type == 'Maintenance')
{
g_form.showFieldMsg('type1','Routine change, update salary ranges)','info',true);
}


}


 
1 ACCEPTED SOLUTION

Abhishek Pidwa
Kilo Guru

I beleive what is happening is that the new value of type1 is None meaning ''. So try to write your code for hiding field message in that first if block. 

 

if (isLoading || newValue == '') {
g_form.hideFieldMsg('type1',true);

return;
}

Please mark this answer as correct/helpful if this solves your problem

View solution in original post

2 REPLIES 2

Abhishek Pidwa
Kilo Guru

I beleive what is happening is that the new value of type1 is None meaning ''. So try to write your code for hiding field message in that first if block. 

 

if (isLoading || newValue == '') {
g_form.hideFieldMsg('type1',true);

return;
}

Please mark this answer as correct/helpful if this solves your problem

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ramesh,

Update the code as below

if (isLoading || newValue == '') {
if(newValue == ''){
g_form.hideFieldMsg('type1',true);

}
return;
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader