Changing "-- None --" in Select Box variables on catalog items

Jim Coyne
Kilo Patron

There is a feature available to change the display value of the "-- None --" option in Select Box fields on forms. Here's the Wiki article - http://wiki.service-now.com/index.php?title=Customizing_Choice_Lists#Changing_the_--_None_--_Display_Value

However, that does not work with Catalog Variables. I created a UI Script that does it for you:


function u_replaceSelectBoxNoneString(variableName, newString) {
try{
var control = g_form.getControl(variableName);
control.options[0].text = newString;
}
catch(err) {}
}


So now you can just call it from an onLoad script to change the string:

function onLoad() {
u_replaceSelectBoxNoneString('action', '-- Please Select --');
}


and you end up with:
find_real_file.png

Bonus - It actually works on forms as well.

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.


View solution in original post

11 REPLIES 11

Dick Eggleston
Kilo Contributor

Or, you can go to "Type Specifications" and uncheck "Include none".  

baqar rizvi
Mega Expert

Hi Jim,

 

That's the article I was looking for, I had a similar requirement in my project need you help.

 

writing the below as UI Script

replaced variable name with name of the variable where --None-- need to be replaced.

Having a doubt what else needs to be changed to make this work.

function u_replaceSelectBoxNoneString(variableName, newString) {
try{
var control = g_form.getControl(variableName);
control.options[0].text = newString;
}
catch(err) {}
}

 

writing the below onLoad catalog Client script in Catalog Item

function onLoad() {
u_replaceSelectBoxNoneString('action', '-- Please Select --');
}