Hide Choice option of multiple choice variable in service catalog

Apoorva2
Kilo Contributor

Hi,

I have to hide choice option from multiple choice variable in catalog item

but my code is not working,here is my code :

function onLoad() {
g_form.removeOption('Select Type of request','disable_account');

}

 

 

12 REPLIES 12

Apoorva2
Kilo Contributor

Hi Ankur,

Its not working

Hi,

this worked for me on native

I have 3 choices and I have set apple value to hidden

function onLoad() {
   //Type appropriate comment here, and begin script below
   
	g_form.getControls('my_choice').forEach(function(e) {
		if (e.value == 'apple')
			e.parentElement.style.display = 'none';
	});
	
}

Variable with 2 choices:

find_real_file.png

Output:

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Apoorva 

Did I answer your original question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Murthy Ch
Giga Sage

Hi @Apoorva 

 

Pls refer this:

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

 

Thanks,

Murthy

Please mark my answer helpful if its solves your query.

Thanks,
Murthy

Try this code:

 

function onLoad() {

//Type appropriate comment here, and begin script below

var choice = document.getElementById("your complete id").parentNode.parentNode; // Use the entire id so that you can hide particular choice.

if (choice){

choice.style.visibility="hidden";

choice.style.display="none";

}

}

 

Thanks,

Murthy

Thanks,
Murthy