Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

FIeld message is not showing up in service portal but working in ITIL view

naveenmyana
Giga Expert

Hello,

I have written a catalog client script to display a field message below a label variable and is working as expected in ITL view but for some reason it is not working in portal. 

I have set the UI type to all in client also but not able to figure out the issue, Please suggest.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
// g_form.hideFieldMsg('terms_of_use',true);
return;
}
var msg = " Some files can be restored without additional help. Please follow the steps to restore the lost file from the shared drive. *If you cannot restore the file please complete the form and submit the request. *• Please select the Shared Drive. *• Right click on folder and click on Properties. *• Click on previous version tab and select the desired previous version. *• Click on Open button & browse for missing files/data. *• Select the required missing file/data. *• Copy those & paste it to User's local disk.";

if(newValue == 'shared_network_drive'){
// alert('test');
var spli = msg.split('*');
var len = spli.length;
for(var i=0; len>i; i++){
g_form.showFieldMsg('terms_of_use',spli[i],'info');
}
}
else{
g_form.hideFieldMsg('terms_of_use',true);
}
// //Type appropriate comment here, and begin script below

}

9 REPLIES 9

RAHUL Khanna1
Mega Guru

1) did you check you have selected the the UI type to all ...

Hi Rahul,

 

Yes, I have set the UI type to all and still its not working..Any other suggestions

palmen
Tera Guru

I would suggest to add some logs, make sure you enter the if() part of your code.

Hello Palmen,

 

Yes, For testing I have put the alerts and they are entering the loop as usual but for some reason message is not displaying. Below is my script.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
// g_form.hideFieldMsg('terms_of_use',true);
return;
}
var msg = "Some files can be restored without additional help. Please follow the steps to restore the lost file from the shared drive. *If you cannot restore the file please complete the form and submit the request. *• Please select the Shared Drive. *• Right click on folder and click on Properties. *• Click on previous version tab and select the desired previous version. *• Click on Open button & browse for missing files/data. *• Select the required missing file/data. *• Copy those & paste it to User's local disk.";

if(newValue == 'shared_network_drive'){
alert('message');
 alert('test');
 var spli = msg.split('*');
 var len = spli.length;
 for(var i=0; len>i; i++){
 alert('Display message');
 g_form.showFieldMsg('terms_of_use',spli[i],'info');
 alert('display 2');
 }
}
else{
alert('hide');
g_form.hideFieldMsg('terms_of_use',true);
}
// //Type appropriate comment here, and begin script below

}