What is the value of -- None -- in select box?

dianemiro
Kilo Sage

Hi Everyone,

I know before that the value of -- None -- in select box is blank or ''. I am creating a client script to clear selections if -- None -- is selected in a select box but I can't get it to work. It seems that the value of -- None -- is not '' or blank. Can you help me to confirm what is the value of None?

Thank you,
Diane

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

it's actually blank 

View solution in original post

8 REPLIES 8

And if you find this too tiring, then just create a ui policy and there you can use the condition builder to select none for field regardless of the value...and use 'execute if true' to run whatever you wanted to run

-Anurag

Harsh Vardhan
Giga Patron

in your script if you want to check then just 

try with script below.

 

if(g_form.getValue('category')=='')  //change the field name
{
alert('hello');
}
else
{
alert('not hellow');
}

Brent Llewellyn
Mega Guru

Unless otherwise defined it is blank. If it is returning a value you may want to check if it is defined in the choices of the dictionary.

If it is blank you may want to look at the Client script. If you are looking to take action on - None - ensure you remove "|| newValue === ''" from the initial if statement in the client script.

See Example Below

// Client script is ended if the value is blank
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   // Code here WILL NOT execute on - None -
}


// Client script is not ended if the value is blank
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	// Removed so that script continues on - None -
   if (isLoading /*|| newValue === ''*/) {
      return;
   }

   // Code here WILL  execute on - None -
}

Rohan_15
Tera Contributor

@dianemiro 

You should use the 'addOption()' method like below

 

g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>) // example given below

g_form.addOption('support_needed', '', '-- None --');
g_form.addOption('support_needed', 'amazon', 'Amazon Prime');

 

 
This will work even if we have Mandatory check for the 'support_needed' making it mandatory even if we toggle between the options(without this way, the first option will be selected while you toggle between the options)

 

if (platform_selected == 'ott'){
    g_form.addOption('support_needed', '', '-- None --');
    g_form.addOption('support_needed', 'amazon', 'Amazon prime');
}else{
    g_form.addOption('support_needed', '', '-- None --');
    g_form.addOption('support_needed', 'national_geograpthy_tv', 'National Geography TV');
}

 

 
The blank value should be used in the above way.


Thanks,
- Rohan