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

Allen Andreas
Administrator
Administrator

Not sure if that is fully the cause, but in your screenshot, you have a different case for "read only" in the remove option for read only vs. what the addOption says (which is Read Only). So maybe that's causing something?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

You also have this thread going on as well...

https://community.servicenow.com/community?id=community_question&sys_id=f05b0931db507b88a39a0b55ca96...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Prateek kumar
Mega Sage

Try this and see if it helps

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

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

this script hides the choices for please select the access