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

lawrence_eng
Administrator
Administrator

Thank you, Jim!


I just received an answer to the HI ticket I had put in a while ago about this. Here's an easier solution:
1. do not check the "Include none" check box
2. add a Question Choice entry with Text equal to the string you want displayed and a Value of "NULL"

It's important that the Value field is "NULL" and not "null", "Null" or any other combination.

The function above is still useful in situations where you cannot add choice values. One example would be a Select Box variable where the values come from a table or for Yes/No variables.


Good day Jim,



If my field is a look up from a table of items, can I assign NULL to one of my table items? I don't see a Value option within table items.


You will need to use the script in that particular case.   Take a look at the Incident form on demo009 at the moment - https://demo009.service-now.com/nav_to.do?uri=incident.do



ServiceNow.png



I added the UI Script and an onLoad Client Script.