The CreatorCon Call for Content is officially open! Get started here.

Blank option on a variable

John Vo1
Tera Guru

Is there a reason why I have a blank option for one of my variable on this catalog item?

find_real_file.png

Is there something in my script that can cause this?

find_real_file.png\

I also have Read Only as a choice under this variable.

1 ACCEPTED SOLUTION

Try this:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue === '') {
		return;
	}
	var test = g_form.getValue('access_needed'); //Change accordingly
	
	g_form.clearOptions('type_of_access');
	
	if(test == 'flowcal mlp'){  //Change accordingly
		g_form.removeOption('type_of_access', 'read only');
        g_form.addOption('type_of_access', 'edit','Edit');
		
	}
	else
		{
        g_form.addOption('type_of_access', 'edit','Edit');
		g_form.addOption('type_of_access', 'read only', 'Read Only' );
	}
}

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

15 REPLIES 15

Hi Prateek,

Just wanted to say thank you for the above post, I was having the same issue and making the below amendment as per your suggestion resolved it!

Original:

g_form.addOption('new_mailbox', 'new mailbox');

Updated:

g_form.addOption('new_mailbox', 'new mailbox', 'New mailbox');

The third option that seems to add a display value doesn't seem to be mentioned in any of the ServiceNow documentation so this was really useful to come across 🙂


Rich